// Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. import * as React from 'react'; import { OptionsManager } from './options_manager'; /** * Interface describing toolbar properties. * * @private */ interface IToolbarProps {} /** * Interface describing toolbar state. * * @private */ interface IToolbarState { /** * Boolean indicating whether numbering is enabled. */ numbering: boolean; } /** * Returns a generator for rendering a Markdown table of contents toolbar. * * @private * @param options - generator options * @returns toolbar generator */ function toolbar(options: OptionsManager) { return class extends React.Component { /** * Returns a generator for rendering a Markdown table of contents toolbar. * * @param props - toolbar properties * @returns toolbar generator */ constructor(props: IToolbarProps) { super(props); this.state = { numbering: false }; options.initializeOptions(false); } /** * Renders a toolbar. * * @returns rendered toolbar */ render() { const toggleNumbering = () => { options.numbering = !options.numbering; this.setState({ numbering: options.numbering }); }; let icon; if (this.state.numbering) { icon = (
toggleNumbering()} >
); } else { icon = (
toggleNumbering()} >
); } return (
{icon}
); } }; } /** * Exports. */ export { toolbar };