Skip to content

Commit

Permalink
feat: wiki editor
Browse files Browse the repository at this point in the history
  • Loading branch information
libra-co committed May 20, 2024
1 parent c2e1b5b commit 1b0256b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions frontend/src/pages/wiki2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Wiki extends Component {
can_edit_file: false,
seadoc_access_token: '',
docUuid: '',
assets_url: '',
};

window.onpopstate = this.onpopstate;
Expand Down Expand Up @@ -206,6 +207,7 @@ class Wiki extends Component {
this.removePythonWrapper();
wikiAPI.getWiki2FileContent(wikiId, filePath).then(res => {
let data = res.data;

this.setState({
isDataLoading: false,
content: data.content,
Expand All @@ -214,6 +216,7 @@ class Wiki extends Component {
latestContributor: data.latest_contributor,
can_edit_file: data.can_edit_file,
seadoc_access_token: data.seadoc_access_token,
assets_url: data.assets_url,
});
}).catch(error => {
let errorMsg = Utils.getErrorMsg(error);
Expand Down Expand Up @@ -592,7 +595,7 @@ class Wiki extends Component {
setCurrentPage={this.setCurrentPage}
currentPageId={this.state.currentPageId}
/>
{<MainPanel
<MainPanel
path={this.state.path}
pathExist={this.state.pathExist}
isViewFile={this.state.isViewFile}
Expand All @@ -607,7 +610,8 @@ class Wiki extends Component {
onMainNavBarClick={this.onMainNavBarClick}
can_edit_file={this.state.can_edit_file}
seadoc_access_token={this.state.seadoc_access_token}
/>}
assets_url={this.state.assets_url}
/>
<MediaQuery query="(max-width: 767.8px)">
<Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal>
</MediaQuery>
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/pages/wiki2/main-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const propTypes = {
onLinkClick: PropTypes.func.isRequired,
can_edit_file: PropTypes.bool,
seadoc_access_token: PropTypes.string,
assets_url: PropTypes.string,
};

class MainPanel extends Component {
Expand Down Expand Up @@ -94,10 +95,11 @@ class MainPanel extends Component {
...config,
...pageOptions,
sdocServer,
assetsUrl,
assetsUrl: assetsUrl || props.assets_url,
can_edit_file,
accessToken: seadoc_access_token,
serviceUrl: config.serviceURL,
assets_url: config.assetsUrl,
};
return { ...props, docUuid: window.seafile.docUuid };
}
Expand Down Expand Up @@ -147,7 +149,7 @@ class MainPanel extends Component {
<div className={`cur-view-content ${isViewingFile ? 'o-hidden' : ''}`}>
{!this.props.pathExist && errMessage}
{this.props.pathExist && this.props.isDataLoading && <Loading />}
{isViewingFile && Utils.isMarkdownFile(this.props.path) && (
{/* {isViewingFile && Utils.isMarkdownFile(this.props.path) && (
<SeafileMarkdownViewer
isWiki={true}
path={this.props.path}
Expand All @@ -158,8 +160,8 @@ class MainPanel extends Component {
latestContributor={this.props.latestContributor}
onLinkClick={this.props.onLinkClick}
/>
)}
{this.props.seadoc_access_token && this.state.docUuid && isViewingFile && Utils.isSdocFile(this.props.path) && (
)} */}
{isViewingFile && Utils.isSdocFile(this.props.path) && (
<WikiViewer
document={editorContent}
showOutline={false}
Expand Down

0 comments on commit 1b0256b

Please sign in to comment.