(source: string, options?: { index?: number })
| 135 | } |
| 136 | |
| 137 | export 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 | } |
| 153 | export async function insertCodeCell(source: string, options?: { language?: string; index?: number }) { |
| 154 | const activeEditor = window.activeNotebookEditor; |
| 155 | if (!activeEditor) { |
no test coverage detected