UNPKG

2.13 kBJavaScriptView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3import { NotebookModel } from './model';
4/**
5 * A model factory for notebooks.
6 */
7export class NotebookModelFactory {
8 /**
9 * Construct a new notebook model factory.
10 */
11 constructor(options) {
12 this._disposed = false;
13 this._disableDocumentWideUndoRedo =
14 options.disableDocumentWideUndoRedo || false;
15 const codeCellContentFactory = options.codeCellContentFactory;
16 this.contentFactory =
17 options.contentFactory ||
18 new NotebookModel.ContentFactory({ codeCellContentFactory });
19 }
20 /**
21 * Define the disableDocumentWideUndoRedo property.
22 */
23 set disableDocumentWideUndoRedo(disableDocumentWideUndoRedo) {
24 this._disableDocumentWideUndoRedo = disableDocumentWideUndoRedo;
25 }
26 /**
27 * The name of the model.
28 */
29 get name() {
30 return 'notebook';
31 }
32 /**
33 * The content type of the file.
34 */
35 get contentType() {
36 return 'notebook';
37 }
38 /**
39 * The format of the file.
40 */
41 get fileFormat() {
42 return 'json';
43 }
44 /**
45 * Get whether the model factory has been disposed.
46 */
47 get isDisposed() {
48 return this._disposed;
49 }
50 /**
51 * Dispose of the model factory.
52 */
53 dispose() {
54 this._disposed = true;
55 }
56 /**
57 * Create a new model for a given path.
58 *
59 * @param languagePreference - An optional kernel language preference.
60 *
61 * @returns A new document model.
62 */
63 createNew(languagePreference, modelDB, isInitialized) {
64 const contentFactory = this.contentFactory;
65 return new NotebookModel({
66 languagePreference,
67 contentFactory,
68 modelDB,
69 isInitialized,
70 disableDocumentWideUndoRedo: this._disableDocumentWideUndoRedo
71 });
72 }
73 /**
74 * Get the preferred kernel language given a path.
75 */
76 preferredLanguage(path) {
77 return '';
78 }
79}
80//# sourceMappingURL=modelfactory.js.map
\No newline at end of file