API updates
This commit is contained in:
Родитель
abfa1f7127
Коммит
475f8e1afa
|
@ -39,7 +39,13 @@ class MarkdownProvider implements vscode.NotebookContentProvider {
|
|||
uri = vscode.Uri.parse(openContext.backupId);
|
||||
}
|
||||
|
||||
const metadata: vscode.NotebookDocumentMetadata = { editable: true, cellEditable: true, cellHasExecutionOrder: false, cellRunnable: false, runnable: false };
|
||||
const metadata = new vscode.NotebookDocumentMetadata().with({
|
||||
editable: true,
|
||||
cellEditable: true,
|
||||
cellHasExecutionOrder: false,
|
||||
cellRunnable: false,
|
||||
runnable: false
|
||||
});
|
||||
const content = Buffer.from(await vscode.workspace.fs.readFile(uri))
|
||||
.toString('utf8');
|
||||
|
||||
|
@ -65,9 +71,9 @@ class MarkdownProvider implements vscode.NotebookContentProvider {
|
|||
|
||||
export function rawToNotebookCellData(data: RawNotebookCell): vscode.NotebookCellData {
|
||||
return <vscode.NotebookCellData>{
|
||||
cellKind: data.kind,
|
||||
kind: data.kind,
|
||||
language: data.language,
|
||||
metadata: { editable: true, runnable: false, custom: { leadingWhitespace: data.leadingWhitespace, trailingWhitespace: data.trailingWhitespace, indentation: data.indentation } },
|
||||
metadata: new vscode.NotebookCellMetadata().with({ editable: true, runnable: false, custom: { leadingWhitespace: data.leadingWhitespace, trailingWhitespace: data.trailingWhitespace, indentation: data.indentation } }),
|
||||
outputs: [],
|
||||
source: data.content
|
||||
};
|
||||
|
|
|
@ -115,9 +115,9 @@ function cellDataToFakeCell(cell: vscode.NotebookCellData): vscode.NotebookCell
|
|||
document: {
|
||||
getText: () => cell.source
|
||||
} as any,
|
||||
cellKind: cell.cellKind,
|
||||
cellKind: cell.kind,
|
||||
language: cell.language,
|
||||
metadata: cell.metadata || {},
|
||||
metadata: cell.metadata || new vscode.NotebookCellMetadata(),
|
||||
index: -1,
|
||||
notebook: undefined as any,
|
||||
outputs: [],
|
||||
|
@ -149,16 +149,16 @@ suite('writeMarkdown', () => {
|
|||
const cells = parseMarkdown(`# hello`)
|
||||
.map(rawToNotebookCellData);
|
||||
cells.push(<vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Markdown,
|
||||
kind: vscode.NotebookCellKind.Markdown,
|
||||
language: 'markdown',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'foo'
|
||||
});
|
||||
cells.push(<vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Markdown,
|
||||
kind: vscode.NotebookCellKind.Markdown,
|
||||
language: 'markdown',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'bar'
|
||||
});
|
||||
|
@ -171,16 +171,16 @@ suite('writeMarkdown', () => {
|
|||
const cells = parseMarkdown('```ts\nsome code\n```')
|
||||
.map(rawToNotebookCellData);
|
||||
cells.push(<vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
kind: vscode.NotebookCellKind.Code,
|
||||
language: 'typescript',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'foo'
|
||||
});
|
||||
cells.push(<vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
kind: vscode.NotebookCellKind.Code,
|
||||
language: 'typescript',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'bar'
|
||||
});
|
||||
|
@ -193,16 +193,16 @@ suite('writeMarkdown', () => {
|
|||
const cells = parseMarkdown('# Hello\n\n## Header 2')
|
||||
.map(rawToNotebookCellData);
|
||||
cells.splice(1, 0, <vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
kind: vscode.NotebookCellKind.Code,
|
||||
language: 'typescript',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'foo'
|
||||
});
|
||||
cells.splice(2, 0, <vscode.NotebookCellData>{
|
||||
cellKind: vscode.NotebookCellKind.Code,
|
||||
kind: vscode.NotebookCellKind.Code,
|
||||
language: 'typescript',
|
||||
metadata: {},
|
||||
metadata: new vscode.NotebookCellMetadata(),
|
||||
outputs: [],
|
||||
source: 'bar'
|
||||
});
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче