#3920: Notebooks file save/save all/cache - for existing files (#4286)

* #3920: Notebooks file save

* Missed in merge

* #4290: Untitled save and native dirty implementation

* Misc changes

* Content Manager, notebooks extension and commented failed unit tests

* Removing modelLoaded event
This commit is contained in:
Raj
2019-03-07 18:07:20 -08:00
committed by GitHub
parent 2a903e9f03
commit 036ffe595a
15 changed files with 486 additions and 400 deletions

View File

@@ -22,6 +22,29 @@ import { nbformat } from 'sql/parts/notebook/models/nbformat';
type MimeBundle = { [key: string]: string | string[] | undefined };
export class LocalContentManager implements nb.ContentManager {
public async loadFromContentString(contentString: string): Promise<nb.INotebookContents> {
let contents: JSONObject = json.parse(contentString);
if (contents) {
if (contents.nbformat === 4) {
return v4.readNotebook(<any>contents);
} else if (contents.nbformat === 3) {
return v3.readNotebook(<any>contents);
}
if (contents.nbformat) {
throw new TypeError(localize('nbformatNotRecognized', 'nbformat v{0}.{1} not recognized', contents.nbformat as any, contents.nbformat_minor as any));
}
} else if (contentString === '' || contentString === undefined) {
// Empty?
return v4.createEmptyNotebook();
}
// else, fallthrough condition
throw new TypeError(localize('nbNotSupported', 'This file does not have a valid notebook format'));
}
public async getNotebookContents(notebookUri: URI): Promise<nb.INotebookContents> {
if (!notebookUri) {
return undefined;