-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtreeview.tsx
47 lines (43 loc) · 1.32 KB
/
treeview.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { VDomRenderer } from '@jupyterlab/ui-components';
import * as React from 'react';
import { TableOfContentsTree } from './toctree';
import { TableOfContents } from './tokens';
/**
* Table of contents widget.
*/
export class TableOfContentsWidget extends VDomRenderer<TableOfContents.IModel<TableOfContents.IHeading> | null> {
/**
* Constructor
*
* @param options Widget options
*/
constructor(options: TableOfContents.IOptions = {}) {
super(options.model);
}
/**
* Render the content of this widget using the virtual DOM.
*
* This method will be called anytime the widget needs to be rendered, which
* includes layout triggered rendering.
*/
render(): JSX.Element | null {
if (!this.model) {
return null;
}
return (
<TableOfContentsTree
activeHeading={this.model.activeHeading}
documentType={this.model.documentType}
headings={this.model.headings}
onCollapseChange={(heading: TableOfContents.IHeading) => {
this.model!.toggleCollapse({ heading });
}}
setActiveHeading={(heading: TableOfContents.IHeading) => {
this.model!.setActiveHeading(heading);
}}
></TableOfContentsTree>
);
}
}