mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Change exportNotebook API to return string
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user