UNPKG

3.78 kBTypeScriptView Raw
1import { ISessionContext, Printing } from '@jupyterlab/apputils';
2import { DocumentWidget } from '@jupyterlab/docregistry';
3import { ITranslator } from '@jupyterlab/translation';
4import { Token } from '@lumino/coreutils';
5import { INotebookModel } from './model';
6import { Notebook, StaticNotebook } from './widget';
7import { Message } from '@lumino/messaging';
8/**
9 * A widget that hosts a notebook toolbar and content area.
10 *
11 * #### Notes
12 * The widget keeps the document metadata in sync with the current
13 * kernel on the context.
14 */
15export declare class NotebookPanel extends DocumentWidget<Notebook, INotebookModel> {
16 /**
17 * Construct a new notebook panel.
18 */
19 constructor(options: DocumentWidget.IOptions<Notebook, INotebookModel>);
20 /**
21 * Handle a change to the document registry save state.
22 *
23 * @param sender The document registry context
24 * @param state The document registry save state
25 */
26 private _onSave;
27 /**
28 * The session context used by the panel.
29 */
30 get sessionContext(): ISessionContext;
31 /**
32 * The model for the widget.
33 */
34 get model(): INotebookModel | null;
35 /**
36 * Update the options for the current notebook panel.
37 *
38 * @param config new options to set
39 */
40 setConfig(config: NotebookPanel.IConfig): void;
41 /**
42 * Set URI fragment identifier.
43 */
44 setFragment(fragment: string): void;
45 /**
46 * Dispose of the resources used by the widget.
47 */
48 dispose(): void;
49 /**
50 * Prints the notebook by converting to HTML with nbconvert.
51 */
52 [Printing.symbol](): () => Promise<void>;
53 /**
54 * A message handler invoked on a 'before-hide' message.
55 */
56 protected onBeforeHide(msg: Message): void;
57 /**
58 * A message handler invoked on a 'before-show' message.
59 */
60 protected onBeforeShow(msg: Message): void;
61 /**
62 * Handle a change in the kernel by updating the document metadata.
63 */
64 private _onKernelChanged;
65 private _onSessionStatusChanged;
66 /**
67 * Update the kernel language.
68 */
69 private _updateLanguage;
70 /**
71 * Update the kernel spec.
72 */
73 private _updateSpec;
74 translator: ITranslator;
75 private _trans;
76 /**
77 * Whether we are currently in a series of autorestarts we have already
78 * notified the user about.
79 */
80 private _autorestarting;
81}
82/**
83 * A namespace for `NotebookPanel` statics.
84 */
85export declare namespace NotebookPanel {
86 /**
87 * Notebook config interface for NotebookPanel
88 */
89 interface IConfig {
90 /**
91 * Whether to automatically start the preferred kernel
92 */
93 autoStartDefault: boolean;
94 /**
95 * A config object for cell editors
96 */
97 editorConfig: StaticNotebook.IEditorConfig;
98 /**
99 * A config object for notebook widget
100 */
101 notebookConfig: StaticNotebook.INotebookConfig;
102 /**
103 * Whether to shut down the kernel when closing the panel or not
104 */
105 kernelShutdown: boolean;
106 }
107 /**
108 * A content factory interface for NotebookPanel.
109 */
110 interface IContentFactory extends Notebook.IContentFactory {
111 /**
112 * Create a new content area for the panel.
113 */
114 createNotebook(options: Notebook.IOptions): Notebook;
115 }
116 /**
117 * The default implementation of an `IContentFactory`.
118 */
119 class ContentFactory extends Notebook.ContentFactory implements IContentFactory {
120 /**
121 * Create a new content area for the panel.
122 */
123 createNotebook(options: Notebook.IOptions): Notebook;
124 }
125 /**
126 * The notebook renderer token.
127 */
128 const IContentFactory: Token<IContentFactory>;
129}