UNPKG

2.35 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 var _a, _b;
13 this._disposed = false;
14 this._disableDocumentWideUndoRedo =
15 (_a = options.disableDocumentWideUndoRedo) !== null && _a !== void 0 ? _a : true;
16 this._collaborative = (_b = options.collaborative) !== null && _b !== void 0 ? _b : true;
17 }
18 /**
19 * Define the disableDocumentWideUndoRedo property.
20 *
21 * @experimental
22 * @alpha
23 */
24 get disableDocumentWideUndoRedo() {
25 return this._disableDocumentWideUndoRedo;
26 }
27 set disableDocumentWideUndoRedo(disableDocumentWideUndoRedo) {
28 this._disableDocumentWideUndoRedo = disableDocumentWideUndoRedo;
29 }
30 /**
31 * The name of the model.
32 */
33 get name() {
34 return 'notebook';
35 }
36 /**
37 * The content type of the file.
38 */
39 get contentType() {
40 return 'notebook';
41 }
42 /**
43 * The format of the file.
44 */
45 get fileFormat() {
46 return 'json';
47 }
48 /**
49 * Whether the model is collaborative or not.
50 */
51 get collaborative() {
52 return this._collaborative;
53 }
54 /**
55 * Get whether the model factory has been disposed.
56 */
57 get isDisposed() {
58 return this._disposed;
59 }
60 /**
61 * Dispose of the model factory.
62 */
63 dispose() {
64 this._disposed = true;
65 }
66 /**
67 * Create a new model for a given path.
68 *
69 * @param languagePreference - An optional kernel language preference.
70 *
71 * @returns A new document model.
72 */
73 createNew(options = {}) {
74 return new NotebookModel({
75 languagePreference: options.languagePreference,
76 sharedModel: options.sharedModel,
77 collaborationEnabled: options.collaborationEnabled && this.collaborative,
78 disableDocumentWideUndoRedo: this._disableDocumentWideUndoRedo
79 });
80 }
81 /**
82 * Get the preferred kernel language given a path.
83 */
84 preferredLanguage(path) {
85 return '';
86 }
87}
88//# sourceMappingURL=modelfactory.js.map
\No newline at end of file