@@ -266,6 +266,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
266
266
return this . _notebookOptions ;
267
267
}
268
268
269
+ get viewContext ( ) {
270
+ return this . _viewContext ;
271
+ }
272
+
269
273
constructor (
270
274
readonly creationOptions : INotebookEditorCreationOptions ,
271
275
dimension : DOM . Dimension | undefined ,
@@ -297,7 +301,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
297
301
this . _viewContext = new ViewContext (
298
302
this . _notebookOptions ,
299
303
new NotebookEventDispatcher ( ) ,
300
- language => this . getBaseCellEditorOptions ( language ) ) ;
304
+ language => this . getBaseCellEditorOptions ( language ) ,
305
+ ( ) => this . _readOnly ) ;
301
306
this . _register ( this . _viewContext . eventDispatcher . onDidChangeCellState ( e => {
302
307
this . _onDidChangeCellState . fire ( e ) ;
303
308
} ) ) ;
@@ -606,7 +611,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
606
611
focusIndicatorGap
607
612
} = this . _notebookOptions . getLayoutConfiguration ( ) ;
608
613
609
- const { bottomToolbarGap, bottomToolbarHeight } = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType ) ;
614
+ const { bottomToolbarGap, bottomToolbarHeight } = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
610
615
611
616
const styleSheets : string [ ] = [ ] ;
612
617
if ( ! this . _fontInfo ) {
@@ -755,7 +760,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
755
760
}
756
761
757
762
// top insert toolbar
758
- const topInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType ) ;
763
+ const topInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
759
764
styleSheets . push ( `.notebookOverlay .cell-list-top-cell-toolbar-container { top: -${ topInsertToolbarHeight - 3 } px }` ) ;
760
765
styleSheets . push ( `.notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element,
761
766
.notebookOverlay > .cell-list-container > .notebook-gutter > .monaco-list > .monaco-scrollable-element {
@@ -1048,12 +1053,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
1048
1053
1049
1054
async setModel ( textModel : NotebookTextModel , viewState : INotebookEditorViewState | undefined , perf ?: NotebookPerfMarks ) : Promise < void > {
1050
1055
if ( this . viewModel === undefined || ! this . viewModel . equal ( textModel ) ) {
1051
- const oldTopInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType ) ;
1052
- const oldBottomToolbarDimensions = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType ) ;
1056
+ const oldTopInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1057
+ const oldBottomToolbarDimensions = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1053
1058
this . _detachModel ( ) ;
1054
1059
await this . _attachModel ( textModel , viewState , perf ) ;
1055
- const newTopInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType ) ;
1056
- const newBottomToolbarDimensions = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType ) ;
1060
+ const newTopInsertToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1061
+ const newBottomToolbarDimensions = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1057
1062
1058
1063
if ( oldTopInsertToolbarHeight !== newTopInsertToolbarHeight
1059
1064
|| oldBottomToolbarDimensions . bottomToolbarGap !== newBottomToolbarDimensions . bottomToolbarGap
@@ -1467,7 +1472,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
1467
1472
} ) ) ;
1468
1473
1469
1474
if ( this . _dimension ) {
1470
- const topInserToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType ) ;
1475
+ const topInserToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1471
1476
this . _list . layout ( this . _dimension . height - topInserToolbarHeight , this . _dimension . width ) ;
1472
1477
} else {
1473
1478
this . _list . layout ( ) ;
@@ -1761,7 +1766,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
1761
1766
const newBodyHeight = Math . max ( dimension . height - ( this . _notebookTopToolbar ?. useGlobalToolbar ? /** Toolbar height */ 26 : 0 ) , 0 ) ;
1762
1767
DOM . size ( this . _body , dimension . width , newBodyHeight ) ;
1763
1768
1764
- const topInserToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType ) ;
1769
+ const topInserToolbarHeight = this . _notebookOptions . computeTopInsertToolbarHeight ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
1765
1770
const newCellListHeight = Math . max ( newBodyHeight - topInserToolbarHeight , 0 ) ;
1766
1771
if ( this . _list . getRenderHeight ( ) < newCellListHeight ) {
1767
1772
// the new dimension is larger than the list viewport, update its additional height first, otherwise the list view will move down a bit (as the `scrollBottom` will move down)
@@ -2934,7 +2939,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
2934
2939
private _updateMarkupCellHeight ( cellId : string , height : number , isInit : boolean ) {
2935
2940
const cell = this . _getCellById ( cellId ) ;
2936
2941
if ( cell && cell instanceof MarkupCellViewModel ) {
2937
- const { bottomToolbarGap } = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType ) ;
2942
+ const { bottomToolbarGap } = this . _notebookOptions . computeBottomToolbarDimensions ( this . viewModel ?. viewType , this . viewModel ?. options . isReadOnly ) ;
2938
2943
this . _debug ( 'updateMarkdownCellHeight' , cell . handle , height + bottomToolbarGap , isInit ) ;
2939
2944
cell . renderedMarkdownHeight = height ;
2940
2945
}
0 commit comments