mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Change exportNotebook API to return string
This commit is contained in:
parent
bc0e917553
commit
1dae051c56
|
@ -19,14 +19,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}));
|
||||
|
||||
return {
|
||||
exportNotebook: (notebook: vscode.NotebookData): Uint8Array => {
|
||||
exportNotebook: (notebook: vscode.NotebookData): string => {
|
||||
return exportNotebook(notebook, serializer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function exportNotebook(notebook: vscode.NotebookData, serializer: NotebookSerializer): Uint8Array {
|
||||
return serializer.serializeNotebook(notebook, new vscode.CancellationTokenSource().token);
|
||||
function exportNotebook(notebook: vscode.NotebookData, serializer: NotebookSerializer): string {
|
||||
return serializer.serializeNotebookToString(notebook);
|
||||
}
|
||||
|
||||
export function deactivate() { }
|
||||
|
|
|
@ -74,10 +74,10 @@ export class NotebookSerializer implements vscode.NotebookSerializer {
|
|||
}
|
||||
|
||||
public serializeNotebook(data: vscode.NotebookData, _token: vscode.CancellationToken): Uint8Array {
|
||||
return new TextEncoder().encode(this.serialize(data));
|
||||
return new TextEncoder().encode(this.serializeNotebookToString(data));
|
||||
}
|
||||
|
||||
private serialize(data: vscode.NotebookData): string {
|
||||
public serializeNotebookToString(data: vscode.NotebookData): string {
|
||||
const notebookContent: Partial<nbformat.INotebookContent> = data.metadata?.custom || {};
|
||||
notebookContent.cells = notebookContent.cells || [];
|
||||
notebookContent.nbformat = notebookContent.nbformat || 4;
|
||||
|
|
Loading…
Reference in a new issue