import React from 'react'; import PropTypes from 'prop-types'; import Modal from 'react-bootstrap/es/Modal'; import Button from 'react-bootstrap/es/Button'; import ButtonGroup from 'react-bootstrap/es/ButtonGroup'; import Navbar from 'react-bootstrap/es/Navbar'; import Nav from 'react-bootstrap/es/Nav'; import NavDropdown from 'react-bootstrap/es/NavDropdown'; import MenuItem from 'react-bootstrap/es/MenuItem'; import { HotTable } from '@handsontable/react'; import MarkdownTable from '../../models/MarkdownTable'; export default class HandsontableModal extends React.Component { constructor(props) { super(props); this.state = { show: false, }; this.settings = { height: 300, rowHeaders: true, colHeaders: true, fixedRowsTop: [0, 1], contextMenu: ['row_above', 'row_below', 'col_left', 'col_right', '---------', 'remove_row', 'remove_col', '---------', 'alignment'], stretchH: 'all', selectionMode: 'multiple', }; this.init = this.init.bind(this); this.cancel = this.cancel.bind(this); this.dispatchSave = this.dispatchSave.bind(this); } componentWillMount() { this.init(this.props.markdownTable); } init(markdownTable) { const initMarkdownTable = markdownTable || new MarkdownTable([ ['col1', 'col2', 'col3'], ['', '', ''], ['', '', ''], ]); this.setState({ markdownTable: initMarkdownTable }); } show(markdownTable, doneHandler) { this.init(markdownTable); this.setState({ show: true }); } cancel() { this.setState({ show: false }); } /** * dispatch save event */ dispatchSave() { if (this.props.onSave != null) { this.props.onSave(this.state.markdownTable); } } render() { return ( Edit Table
); } } HandsontableModal.propTypes = { markdownTable: PropTypes.instanceOf(MarkdownTable), onSave: PropTypes.func, };