@@ -59,6 +59,7 @@ interface Props {
59
59
isFirst ?: boolean ;
60
60
isLast ?: boolean ;
61
61
dragHandle ?: JSX . Element ;
62
+ read_only ?: boolean ;
62
63
}
63
64
64
65
function areEqual ( props : Props , nextProps : Props ) : boolean {
@@ -86,7 +87,8 @@ function areEqual(props: Props, nextProps: Props): boolean {
86
87
( nextProps . llmTools ?. model ?? "" ) !== ( props . llmTools ?. model ?? "" ) ||
87
88
( nextProps . complete !== props . complete && // only worry about complete when editing this cell
88
89
( nextProps . is_current || props . is_current ) ) ||
89
- nextProps . dragHandle !== props . dragHandle
90
+ nextProps . dragHandle !== props . dragHandle ||
91
+ nextProps . read_only !== props . read_only
90
92
) ;
91
93
}
92
94
@@ -101,7 +103,10 @@ export const Cell: React.FC<Props> = React.memo((props: Props) => {
101
103
}
102
104
103
105
function is_editable ( ) : boolean {
104
- return props . cell . getIn ( [ "metadata" , "editable" ] , true ) as any ;
106
+ return (
107
+ ! props . read_only &&
108
+ ( props . cell . getIn ( [ "metadata" , "editable" ] , true ) as any )
109
+ ) ;
105
110
}
106
111
107
112
function is_deletable ( ) : boolean {
@@ -175,6 +180,9 @@ export const Cell: React.FC<Props> = React.memo((props: Props) => {
175
180
}
176
181
177
182
function double_click ( event : any ) : void {
183
+ if ( props . read_only ) {
184
+ return ;
185
+ }
178
186
if ( props . cell . getIn ( [ "metadata" , "editable" ] ) === false ) {
179
187
return ;
180
188
}
@@ -378,7 +386,7 @@ export const Cell: React.FC<Props> = React.memo((props: Props) => {
378
386
// Note that the cell id is used for scroll functionality, so *is* important.
379
387
return (
380
388
< >
381
- { render_insert_cell ( "above" ) }
389
+ { ! props . read_only && render_insert_cell ( "above" ) }
382
390
< div
383
391
style = { getCellStyle ( ) }
384
392
onMouseUp = { props . is_current ? undefined : click_on_cell }
@@ -390,7 +398,7 @@ export const Cell: React.FC<Props> = React.memo((props: Props) => {
390
398
{ render_cell_input ( props . cell ) }
391
399
{ render_cell_output ( props . cell ) }
392
400
</ div >
393
- { render_insert_cell ( "below" ) }
401
+ { ! props . read_only && render_insert_cell ( "below" ) }
394
402
</ >
395
403
) ;
396
404
} , areEqual ) ;
0 commit comments