forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactory.ts
More file actions
55 lines (53 loc) · 1.93 KB
/
factory.ts
File metadata and controls
55 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { nbformat } from '@jupyterlab/coreutils/lib/nbformat';
import { inject, injectable } from 'inversify';
import { Memento, Uri } from 'vscode';
import { UseVSCodeNotebookEditorApi } from '../../common/constants';
import { ICryptoUtils } from '../../common/types';
import { ICell, INotebookModel } from '../types';
import { NativeEditorNotebookModel } from './notebookModel';
import { INotebookModelFactory } from './types';
import { VSCodeNotebookModel } from './vscNotebookModel';
@injectable()
export class NotebookModelFactory implements INotebookModelFactory {
constructor(@inject(UseVSCodeNotebookEditorApi) private readonly useVSCodeNotebookEditorApi: boolean) {}
public createModel(
options: {
trusted: boolean;
file: Uri;
cells: ICell[];
notebookJson?: Partial<nbformat.INotebookContent>;
globalMemento: Memento;
crypto: ICryptoUtils;
indentAmount?: string;
pythonNumber?: number;
initiallyDirty?: boolean;
},
forVSCodeNotebook?: boolean
): INotebookModel {
if (forVSCodeNotebook || this.useVSCodeNotebookEditorApi) {
return new VSCodeNotebookModel(
options.trusted,
options.file,
options.cells,
options.globalMemento,
options.crypto,
options.notebookJson,
options.indentAmount,
options.pythonNumber
);
}
return new NativeEditorNotebookModel(
options.trusted,
options.file,
options.cells,
options.globalMemento,
options.crypto,
options.notebookJson,
options.indentAmount,
options.pythonNumber,
options.initiallyDirty
);
}
}