import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import PagePathAutoComplete from '../PagePathAutoComplete'; export default class LinkEditModal extends React.PureComponent { constructor(props) { super(props); this.state = { show: false, isUseRelativePath: false, linkInputValue: '', labelInputValue: '', output: '[label](link)', }; this.show = this.show.bind(this); this.hide = this.hide.bind(this); this.cancel = this.cancel.bind(this); this.inputChangeHandler = this.inputChangeHandler.bind(this); this.submitHandler = this.submitHandler.bind(this); this.toggleIsUseRelativePath = this.toggleIsUseRelativePath.bind(this); this.showLog = this.showLog.bind(this); this.save = this.save.bind(this); } show(defaultLabelInputValue = '') { this.setState({ show: true, labelInputValue: defaultLabelInputValue }); } cancel() { this.hide(); } hide() { this.setState({ show: false, }); } toggleIsUseRelativePath() { this.setState({ isUseRelativePath: !this.state.isUseRelativePath }); } renderPreview() { // TODO GW-2658 } insertLinkIntoEditor() { // TODO GW-2659 } showLog() { console.log(this.state.linkInputValue); } save() { if (this.props.onSave != null) { this.props.onSave(this.state.output); } this.hide(); } inputChangeHandler(inputChangeValue) { this.setState({ linkInputValue: inputChangeValue }); } submitHandler(submitValue) { this.setState({ linkInputValue: submitValue }); } render() { return ( Edit Links
{this.renderPreview} render preview
this.labelInputChange(e.target.value)} />
[[{this.state.labelInputValue} > {this.state.linkInputValue}]]
URI
URI
{this.renderPreview} render preview
); } } LinkEditModal.propTypes = { onSave: PropTypes.func, };