Skip to content

Commit f83986a

Browse files
authoredFeb 20, 2024··
Add react-perfect-scrollbar directly to notebook (#13338)
1 parent 384557b commit f83986a

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed
 

‎packages/notebook/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@theia/editor": "1.46.0",
88
"@theia/filesystem": "1.46.0",
99
"@theia/monaco": "1.46.0",
10+
"react-perfect-scrollbar": "^1.5.8",
1011
"uuid": "^8.3.2"
1112
},
1213
"publishConfig": {

‎packages/notebook/src/browser/notebook-editor-widget.tsx

+13-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import { NotebookEditorWidgetService } from './service/notebook-editor-widget-se
3030
import { NotebookMainToolbarRenderer } from './view/notebook-main-toolbar';
3131
import { Deferred } from '@theia/core/lib/common/promise-util';
3232

33+
const PerfectScrollbar = require('react-perfect-scrollbar');
34+
3335
export const NotebookEditorWidgetContainerFactory = Symbol('NotebookEditorWidgetContainerFactory');
3436

3537
export function createNotebookEditorWidgetContainer(parent: interfaces.Container, props: NotebookEditorProps): interfaces.Container {
@@ -102,6 +104,10 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
102104
this.id = NOTEBOOK_EDITOR_ID_PREFIX + this.props.uri.toString();
103105
this.node.tabIndex = -1;
104106

107+
this.scrollOptions = {
108+
suppressScrollY: true
109+
};
110+
105111
this.title.closable = true;
106112
this.update();
107113

@@ -145,12 +151,14 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
145151

146152
protected render(): ReactNode {
147153
if (this._model) {
148-
return <div>
154+
return <div className='theia-notebook-main-container'>
149155
{this.notebookMainToolbarRenderer.render(this._model)}
150-
<NotebookCellListView renderers={this.renderers}
151-
notebookModel={this._model}
152-
toolbarRenderer={this.cellToolbarFactory}
153-
commandRegistry={this.commandRegistry} />
156+
<PerfectScrollbar className='theia-notebook-scroll-container'>
157+
<NotebookCellListView renderers={this.renderers}
158+
notebookModel={this._model}
159+
toolbarRenderer={this.cellToolbarFactory}
160+
commandRegistry={this.commandRegistry} />
161+
</PerfectScrollbar>
154162
</div>;
155163
} else {
156164
return <div></div>;

‎packages/notebook/src/browser/style/index.css

+13-2
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,20 @@
161161
flex-direction: column;
162162
}
163163

164+
.theia-notebook-main-container {
165+
display: flex;
166+
flex-direction: column;
167+
height: 100%;
168+
overflow: hidden;
169+
}
170+
171+
.theia-notebook-scroll-container {
172+
flex: 1;
173+
overflow: hidden;
174+
position: relative;
175+
}
176+
164177
.theia-notebook-main-toolbar {
165-
position: sticky;
166-
top: 0;
167178
background: var(--theia-editor-background);
168179
display: flex;
169180
flex-direction: row;

‎yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -9700,7 +9700,7 @@ react-is@^18.0.0:
97009700
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
97019701
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
97029702

9703-
react-perfect-scrollbar@^1.5.3:
9703+
react-perfect-scrollbar@^1.5.3, react-perfect-scrollbar@^1.5.8:
97049704
version "1.5.8"
97059705
resolved "https://registry.yarnpkg.com/react-perfect-scrollbar/-/react-perfect-scrollbar-1.5.8.tgz#380959387a325c5c9d0268afc08b3f73ed5b3078"
97069706
integrity sha512-bQ46m70gp/HJtiBOF3gRzBISSZn8FFGNxznTdmTG8AAwpxG1bJCyn7shrgjEvGSQ5FJEafVEiosY+ccER11OSA==

0 commit comments

Comments
 (0)
Please sign in to comment.