MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / insertMarkdownCell

Function insertMarkdownCell

src/test/datascience/notebook/helper.ts:137–152  ·  view source on GitHub ↗
(source: string, options?: { index?: number })

Source from the content-addressed store, hash-verified

135}
136
137export async function insertMarkdownCell(source: string, options?: { index?: number }) {
138 await getServices();
139 const activeEditor = window.activeNotebookEditor;
140 if (!activeEditor) {
141 throw new Error('No active editor');
142 }
143 const startNumber = options?.index ?? activeEditor.notebook.cellCount;
144 await chainWithPendingUpdates(activeEditor.notebook, (edit) => {
145 const cellData = new NotebookCellData(NotebookCellKind.Markup, source, MARKDOWN_LANGUAGE);
146 cellData.outputs = [];
147 cellData.metadata = {};
148 const nbEdit = NotebookEdit.insertCells(startNumber, [cellData]);
149 edit.set(activeEditor.notebook.uri, [nbEdit]);
150 });
151 return activeEditor.notebook.cellAt(startNumber)!;
152}
153export async function insertCodeCell(source: string, options?: { language?: string; index?: number }) {
154 const activeEditor = window.activeNotebookEditor;
155 if (!activeEditor) {

Callers 1

Calls 4

getServicesFunction · 0.85
insertCellsMethod · 0.80
cellAtMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected