import React from 'react'; import PropTypes from 'prop-types'; import { EventBus, EXTERNAL_EVENT } from '@seafile/sdoc-editor'; import InternalLinkDialog from '../../components/dialog/internal-link-dialog'; const propTypes = { repoID: PropTypes.string.isRequired, docPath: PropTypes.string.isRequired, }; class ExternalOperations extends React.Component { constructor(props) { super(props); this.state = { isShowInternalLinkDialog: false, }; } componentDidMount() { const eventBus = EventBus.getInstance(); this.unsubscribeInternalLinkEvent = eventBus.subscribe(EXTERNAL_EVENT.INTERNAL_LINK_CLICK, this.onInternalLinkToggle); } componentWillUnmount() { this.unsubscribeInternalLinkEvent(); } onInternalLinkToggle = () => { this.setState({isShowInternalLinkDialog: !this.state.isShowInternalLinkDialog}); } render() { const { repoID, docPath } = this.props; const { isShowInternalLinkDialog } = this.state; return ( <> {isShowInternalLinkDialog && ( )} ); } } ExternalOperations.propTypes = propTypes; export default ExternalOperations;