mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
52
frontend/src/pages/sdoc-editor/external-operations.js
Normal file
52
frontend/src/pages/sdoc-editor/external-operations.js
Normal file
@@ -0,0 +1,52 @@
|
||||
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 && (
|
||||
<InternalLinkDialog
|
||||
repoID={repoID}
|
||||
path={docPath}
|
||||
onInternalLinkDialogToggle={this.onInternalLinkToggle}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ExternalOperations.propTypes = propTypes;
|
||||
|
||||
export default ExternalOperations;
|
15
frontend/src/pages/sdoc-editor/index.js
Normal file
15
frontend/src/pages/sdoc-editor/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { SimpleEditor } from '@seafile/sdoc-editor';
|
||||
import ExternalOperations from './external-operations';
|
||||
|
||||
export default class SdocEditor extends React.Component {
|
||||
render() {
|
||||
const { repoID, docPath } = window.seafile;
|
||||
return (
|
||||
<Fragment>
|
||||
<SimpleEditor />
|
||||
<ExternalOperations repoID={repoID} docPath={docPath} />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import ReactDom from 'react-dom';
|
||||
import { SimpleEditor } from '@seafile/sdoc-editor';
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
import i18n from './_i18n/i18n-sdoc-editor';
|
||||
import { Utils } from './utils/utils';
|
||||
import Loading from './components/loading';
|
||||
import SdocEditor from './pages/sdoc-editor';
|
||||
|
||||
const { serviceURL, avatarURL, siteRoot } = window.app.config;
|
||||
const { username, name } = window.app.userInfo;
|
||||
@@ -34,7 +34,7 @@ window.seafile = {
|
||||
ReactDom.render(
|
||||
<I18nextProvider i18n={ i18n } >
|
||||
<Suspense fallback={<Loading />}>
|
||||
<SimpleEditor />
|
||||
<SdocEditor />
|
||||
</Suspense>
|
||||
</I18nextProvider>,
|
||||
document.getElementById('wrapper')
|
||||
|
Reference in New Issue
Block a user