UNPKG

4.45 kBTypeScriptView Raw
1import { Widget } from '@lumino/widgets';
2import { CodeEditor, CodeEditorWrapper } from '@jupyterlab/codeeditor';
3import { ICellModel } from './model';
4/** ****************************************************************************
5 * InputArea
6 ******************************************************************************/
7/**
8 * An input area widget, which hosts a prompt and an editor widget.
9 */
10export declare class InputArea extends Widget {
11 /**
12 * Construct an input area widget.
13 */
14 constructor(options: InputArea.IOptions);
15 /**
16 * The model used by the widget.
17 */
18 readonly model: ICellModel;
19 /**
20 * The content factory used by the widget.
21 */
22 readonly contentFactory: InputArea.IContentFactory;
23 /**
24 * Get the CodeEditorWrapper used by the cell.
25 */
26 get editorWidget(): CodeEditorWrapper;
27 /**
28 * Get the CodeEditor used by the cell.
29 */
30 get editor(): CodeEditor.IEditor;
31 /**
32 * Get the prompt node used by the cell.
33 */
34 get promptNode(): HTMLElement;
35 /**
36 * Get the rendered input area widget, if any.
37 */
38 get renderedInput(): Widget;
39 /**
40 * Render an input instead of the text editor.
41 */
42 renderInput(widget: Widget): void;
43 /**
44 * Show the text editor.
45 */
46 showEditor(): void;
47 /**
48 * Set the prompt of the input area.
49 */
50 setPrompt(value: string): void;
51 /**
52 * Dispose of the resources held by the widget.
53 */
54 dispose(): void;
55 private _prompt;
56 private _editor;
57 private _rendered;
58}
59/**
60 * A namespace for `InputArea` statics.
61 */
62export declare namespace InputArea {
63 /**
64 * The options used to create an `InputArea`.
65 */
66 interface IOptions {
67 /**
68 * The model used by the widget.
69 */
70 model: ICellModel;
71 /**
72 * The content factory used by the widget to create children.
73 */
74 contentFactory: IContentFactory;
75 /**
76 * Editor options
77 */
78 editorOptions?: Omit<CodeEditor.IOptions, 'host' | 'model'>;
79 }
80 /**
81 * An input area widget content factory.
82 *
83 * The content factory is used to create children in a way
84 * that can be customized.
85 */
86 interface IContentFactory {
87 /**
88 * The editor factory we need to include in `CodeEditorWrapper.IOptions`.
89 *
90 * This is a separate readonly attribute rather than a factory method as we need
91 * to pass it around.
92 */
93 readonly editorFactory: CodeEditor.Factory;
94 /**
95 * Create an input prompt.
96 */
97 createInputPrompt(): IInputPrompt;
98 }
99 /**
100 * Default implementation of `IContentFactory`.
101 *
102 * This defaults to using an `editorFactory` based on CodeMirror.
103 */
104 class ContentFactory implements IContentFactory {
105 /**
106 * Construct a `ContentFactory`.
107 */
108 constructor(options: ContentFactory.IOptions);
109 /**
110 * Return the `CodeEditor.Factory` being used.
111 */
112 get editorFactory(): CodeEditor.Factory;
113 /**
114 * Create an input prompt.
115 */
116 createInputPrompt(): IInputPrompt;
117 private _editor;
118 }
119 /**
120 * A namespace for the input area content factory.
121 */
122 namespace ContentFactory {
123 /**
124 * Options for the content factory.
125 */
126 interface IOptions {
127 /**
128 * The editor factory used by the content factory.
129 *
130 * If this is not passed, a default CodeMirror editor factory
131 * will be used.
132 */
133 editorFactory: CodeEditor.Factory;
134 }
135 }
136}
137/** ****************************************************************************
138 * InputPrompt
139 ******************************************************************************/
140/**
141 * The interface for the input prompt.
142 */
143export interface IInputPrompt extends Widget {
144 /**
145 * The execution count of the prompt.
146 */
147 executionCount: string | null;
148}
149/**
150 * The default input prompt implementation.
151 */
152export declare class InputPrompt extends Widget implements IInputPrompt {
153 constructor();
154 /**
155 * The execution count for the prompt.
156 */
157 get executionCount(): string | null;
158 set executionCount(value: string | null);
159 private _executionCount;
160}