@@ -51,8 +51,11 @@ export interface ICellViewModel {
51
51
}
52
52
53
53
export class Cell extends React . Component < ICellProps > {
54
+ private code : Code | undefined ;
55
+
54
56
constructor ( prop : ICellProps ) {
55
57
super ( prop ) ;
58
+ this . state = { focused : this . props . autoFocus } ;
56
59
}
57
60
58
61
public render ( ) {
@@ -106,11 +109,12 @@ export class Cell extends React.Component<ICellProps> {
106
109
const results : JSX . Element [ ] = this . renderResults ( ) ;
107
110
const allowsPlainInput = getSettings ( ) . showCellInputCode || this . props . cellVM . directInput || this . props . cellVM . editable ;
108
111
const shouldRender = allowsPlainInput || ( results && results . length > 0 ) ;
112
+ const cellOuterClass = this . props . cellVM . editable ? 'cell-outer-editable' : 'cell-outer' ;
109
113
110
114
// Only render if we are allowed to.
111
115
if ( shouldRender ) {
112
116
return (
113
- < div className = 'cell-wrapper' >
117
+ < div className = 'cell-wrapper' role = 'row' onClick = { this . onMouseClick } >
114
118
< MenuBar baseTheme = { this . props . baseTheme } >
115
119
< CellButton baseTheme = { this . props . baseTheme } onClick = { this . props . delete } tooltip = { this . getDeleteString ( ) } hidden = { this . props . cellVM . editable } >
116
120
< Image baseTheme = { this . props . baseTheme } class = 'cell-button-image' image = { ImageName . Cancel } />
@@ -119,10 +123,8 @@ export class Cell extends React.Component<ICellProps> {
119
123
< Image baseTheme = { this . props . baseTheme } class = 'cell-button-image' image = { ImageName . GoToSourceCode } />
120
124
</ CellButton >
121
125
</ MenuBar >
122
- < div className = 'cell-outer' >
123
- < div className = 'controls-div' >
124
- { this . renderControls ( ) }
125
- </ div >
126
+ < div className = { cellOuterClass } >
127
+ { this . renderControls ( ) }
126
128
< div className = 'content-div' >
127
129
< div className = 'cell-result-container' >
128
130
{ this . renderInputs ( ) }
@@ -138,6 +140,13 @@ export class Cell extends React.Component<ICellProps> {
138
140
return null ;
139
141
}
140
142
143
+ private onMouseClick = ( ev : React . MouseEvent < HTMLDivElement > ) => {
144
+ // When we receive a click, tell the code element.
145
+ if ( this . code ) {
146
+ this . code . onParentClick ( ev ) ;
147
+ }
148
+ }
149
+
141
150
private showInputs = ( ) : boolean => {
142
151
return ( this . isCodeCell ( ) && ( this . props . cellVM . inputBlockShow || this . props . cellVM . editable ) ) ;
143
152
}
@@ -155,20 +164,32 @@ export class Cell extends React.Component<ICellProps> {
155
164
const collapseVisible = ( this . props . cellVM . inputBlockCollapseNeeded && this . props . cellVM . inputBlockShow && ! this . props . cellVM . editable ) ;
156
165
const executionCount = this . props . cellVM && this . props . cellVM . cell && this . props . cellVM . cell . data && this . props . cellVM . cell . data . execution_count ?
157
166
this . props . cellVM . cell . data . execution_count . toString ( ) : '0' ;
158
- const afterExecution = this . props . cellVM . editable ?
159
- < CommandPrompt /> :
160
- < CollapseButton theme = { this . props . baseTheme }
167
+
168
+ // Only code cells have controls. Markdown should be empty
169
+ if ( this . isCodeCell ( ) ) {
170
+
171
+ return this . props . cellVM . editable ?
172
+ (
173
+ < div className = 'controls-div' >
174
+ < CommandPrompt />
175
+ </ div >
176
+ ) : (
177
+ < div className = 'controls-div' >
178
+ < ExecutionCount isBusy = { busy } count = { executionCount } visible = { this . isCodeCell ( ) } />
179
+ < CollapseButton theme = { this . props . baseTheme }
161
180
visible = { collapseVisible }
162
181
open = { this . props . cellVM . inputBlockOpen }
163
182
onClick = { this . toggleInputBlock }
164
- tooltip = { getLocString ( 'DataScience.collapseInputTooltip' , 'Collapse input block' ) } /> ;
165
-
166
- return (
167
- < div className = 'controls-flex' >
168
- < ExecutionCount isBusy = { busy } count = { executionCount } visible = { this . isCodeCell ( ) } />
169
- { afterExecution }
170
- </ div >
171
- ) ;
183
+ tooltip = { getLocString ( 'DataScience.collapseInputTooltip' , 'Collapse input block' ) } />
184
+ </ div >
185
+ ) ;
186
+ } else {
187
+ return null ;
188
+ }
189
+ }
190
+
191
+ private updateCodeRef = ( ref : Code ) => {
192
+ this . code = ref ;
172
193
}
173
194
174
195
private renderInputs = ( ) => {
@@ -185,6 +206,7 @@ export class Cell extends React.Component<ICellProps> {
185
206
readOnly = { ! this . props . cellVM . editable }
186
207
onSubmit = { this . props . submitNewCode }
187
208
onChangeLineCount = { this . onChangeLineCount }
209
+ ref = { this . updateCodeRef }
188
210
/>
189
211
</ div >
190
212
) ;
0 commit comments