1 |
|
2 |
|
3 | import { sessionContextDialogs } from '@jupyterlab/apputils';
|
4 | import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
5 | import { ToolbarItems } from './default-toolbar';
|
6 | import { NotebookPanel } from './panel';
|
7 | import { StaticNotebook } from './widget';
|
8 |
|
9 |
|
10 |
|
11 | export class NotebookWidgetFactory extends ABCWidgetFactory {
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 | constructor(options) {
|
18 | super(options);
|
19 | this.rendermime = options.rendermime;
|
20 | this.contentFactory =
|
21 | options.contentFactory || NotebookPanel.defaultContentFactory;
|
22 | this.mimeTypeService = options.mimeTypeService;
|
23 | this._editorConfig =
|
24 | options.editorConfig || StaticNotebook.defaultEditorConfig;
|
25 | this._notebookConfig =
|
26 | options.notebookConfig || StaticNotebook.defaultNotebookConfig;
|
27 | this._sessionDialogs = options.sessionDialogs || sessionContextDialogs;
|
28 | }
|
29 | |
30 |
|
31 |
|
32 | get editorConfig() {
|
33 | return this._editorConfig;
|
34 | }
|
35 | set editorConfig(value) {
|
36 | this._editorConfig = value;
|
37 | }
|
38 | |
39 |
|
40 |
|
41 | get notebookConfig() {
|
42 | return this._notebookConfig;
|
43 | }
|
44 | set notebookConfig(value) {
|
45 | this._notebookConfig = value;
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | createNewWidget(context, source) {
|
54 | const nbOptions = {
|
55 | rendermime: source
|
56 | ? source.content.rendermime
|
57 | : this.rendermime.clone({ resolver: context.urlResolver }),
|
58 | contentFactory: this.contentFactory,
|
59 | mimeTypeService: this.mimeTypeService,
|
60 | editorConfig: source ? source.content.editorConfig : this._editorConfig,
|
61 | notebookConfig: source
|
62 | ? source.content.notebookConfig
|
63 | : this._notebookConfig,
|
64 | translator: this.translator
|
65 | };
|
66 | const content = this.contentFactory.createNotebook(nbOptions);
|
67 | return new NotebookPanel({ context, content });
|
68 | }
|
69 | |
70 |
|
71 |
|
72 | defaultToolbarFactory(widget) {
|
73 | return ToolbarItems.getDefaultItems(widget, this._sessionDialogs, this.translator);
|
74 | }
|
75 | }
|
76 |
|
\ | No newline at end of file |