UNPKG

4.9 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 * Defaults to one that uses CodeMirror.
75 */
76 contentFactory?: IContentFactory;
77 /**
78 * Whether to send an update request to the editor when it is shown.
79 */
80 updateOnShow?: boolean;
81 /**
82 * Whether this input area is a placeholder for future rendering.
83 */
84 placeholder?: boolean;
85 }
86 /**
87 * An input area widget content factory.
88 *
89 * The content factory is used to create children in a way
90 * that can be customized.
91 */
92 interface IContentFactory {
93 /**
94 * The editor factory we need to include in `CodeEditorWrapper.IOptions`.
95 *
96 * This is a separate readonly attribute rather than a factory method as we need
97 * to pass it around.
98 */
99 readonly editorFactory: CodeEditor.Factory;
100 /**
101 * Create an input prompt.
102 */
103 createInputPrompt(): IInputPrompt;
104 }
105 /**
106 * Default implementation of `IContentFactory`.
107 *
108 * This defaults to using an `editorFactory` based on CodeMirror.
109 */
110 class ContentFactory implements IContentFactory {
111 /**
112 * Construct a `ContentFactory`.
113 */
114 constructor(options?: ContentFactory.IOptions);
115 /**
116 * Return the `CodeEditor.Factory` being used.
117 */
118 get editorFactory(): CodeEditor.Factory;
119 /**
120 * Create an input prompt.
121 */
122 createInputPrompt(): IInputPrompt;
123 private _editor;
124 }
125 /**
126 * A namespace for the input area content factory.
127 */
128 namespace ContentFactory {
129 /**
130 * Options for the content factory.
131 */
132 interface IOptions {
133 /**
134 * The editor factory used by the content factory.
135 *
136 * If this is not passed, a default CodeMirror editor factory
137 * will be used.
138 */
139 editorFactory?: CodeEditor.Factory;
140 }
141 }
142 /**
143 * The default editor factory singleton based on CodeMirror.
144 */
145 const defaultEditorFactory: CodeEditor.Factory;
146 /**
147 * The default `ContentFactory` instance.
148 */
149 const defaultContentFactory: ContentFactory;
150}
151/** ****************************************************************************
152 * InputPrompt
153 ******************************************************************************/
154/**
155 * The interface for the input prompt.
156 */
157export interface IInputPrompt extends Widget {
158 /**
159 * The execution count of the prompt.
160 */
161 executionCount: string | null;
162}
163/**
164 * The default input prompt implementation.
165 */
166export declare class InputPrompt extends Widget implements IInputPrompt {
167 constructor();
168 /**
169 * The execution count for the prompt.
170 */
171 get executionCount(): string | null;
172 set executionCount(value: string | null);
173 private _executionCount;
174}