mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 19:01:42 +00:00
feat: wiki editor
This commit is contained in:
@@ -46,6 +46,9 @@ class Wiki extends Component {
|
|||||||
currentPageId: '',
|
currentPageId: '',
|
||||||
config: new WikiConfig({}),
|
config: new WikiConfig({}),
|
||||||
repoId: '',
|
repoId: '',
|
||||||
|
can_edit_file: false,
|
||||||
|
seadoc_access_token: '',
|
||||||
|
docUuid: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
window.onpopstate = this.onpopstate;
|
window.onpopstate = this.onpopstate;
|
||||||
@@ -153,7 +156,7 @@ class Wiki extends Component {
|
|||||||
|
|
||||||
if (isDir === 'False') {
|
if (isDir === 'False') {
|
||||||
// this.showFile(initialPath);
|
// this.showFile(initialPath);
|
||||||
this.setState({path: initialPath});
|
this.setState({ path: initialPath });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,9 +174,9 @@ class Wiki extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isDir === 'None') {
|
if (isDir === 'None') {
|
||||||
this.setState({pathExist: false});
|
this.setState({ pathExist: false });
|
||||||
let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(initialPath);
|
let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(initialPath);
|
||||||
window.history.pushState({url: fileUrl, path: initialPath}, initialPath, fileUrl);
|
window.history.pushState({ url: fileUrl, path: initialPath }, initialPath, fileUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,7 +194,7 @@ class Wiki extends Component {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({isLoadFailed: true});
|
this.setState({ isLoadFailed: true });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -201,7 +204,7 @@ class Wiki extends Component {
|
|||||||
|
|
||||||
// update location url
|
// update location url
|
||||||
let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(dirPath);
|
let fileUrl = siteRoot + this.handlePath() + wikiId + Utils.encodePath(dirPath);
|
||||||
window.history.pushState({url: fileUrl, path: dirPath}, dirPath, fileUrl);
|
window.history.pushState({ url: fileUrl, path: dirPath }, dirPath, fileUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
showFile = (filePath) => {
|
showFile = (filePath) => {
|
||||||
@@ -220,6 +223,8 @@ class Wiki extends Component {
|
|||||||
permission: data.permission,
|
permission: data.permission,
|
||||||
lastModified: moment.unix(data.last_modified).fromNow(),
|
lastModified: moment.unix(data.last_modified).fromNow(),
|
||||||
latestContributor: data.latest_contributor,
|
latestContributor: data.latest_contributor,
|
||||||
|
can_edit_file: data.can_edit_file,
|
||||||
|
seadoc_access_token: data.seadoc_access_token,
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
let errorMsg = Utils.getErrorMsg(error);
|
let errorMsg = Utils.getErrorMsg(error);
|
||||||
@@ -229,14 +234,14 @@ class Wiki extends Component {
|
|||||||
const hash = window.location.hash;
|
const hash = window.location.hash;
|
||||||
let fileUrl = `${siteRoot}${this.handlePath()}${wikiId}${Utils.encodePath(filePath)}${hash}`;
|
let fileUrl = `${siteRoot}${this.handlePath()}${wikiId}${Utils.encodePath(filePath)}${hash}`;
|
||||||
if (filePath === '/home.md') {
|
if (filePath === '/home.md') {
|
||||||
window.history.replaceState({url: fileUrl, path: filePath}, filePath, fileUrl);
|
window.history.replaceState({ url: fileUrl, path: filePath }, filePath, fileUrl);
|
||||||
} else {
|
} else {
|
||||||
window.history.pushState({url: fileUrl, path: filePath}, filePath, fileUrl);
|
window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadDirentList = (dirPath) => {
|
loadDirentList = (dirPath) => {
|
||||||
this.setState({isDataLoading: true});
|
this.setState({ isDataLoading: true });
|
||||||
wikiAPI.listWiki2Dir(wikiId, dirPath).then(res => {
|
wikiAPI.listWiki2Dir(wikiId, dirPath).then(res => {
|
||||||
let direntList = res.data.dirent_list.map(item => {
|
let direntList = res.data.dirent_list.map(item => {
|
||||||
let dirent = new Dirent(item);
|
let dirent = new Dirent(item);
|
||||||
@@ -259,7 +264,7 @@ class Wiki extends Component {
|
|||||||
isDataLoading: false,
|
isDataLoading: false,
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({isLoadFailed: true});
|
this.setState({ isLoadFailed: true });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,7 +284,7 @@ class Wiki extends Component {
|
|||||||
} else {
|
} else {
|
||||||
let parentNode = tree.getNodeByPath(node.parentNode.path);
|
let parentNode = tree.getNodeByPath(node.parentNode.path);
|
||||||
parentNode.isExpanded = true;
|
parentNode.isExpanded = true;
|
||||||
this.setState({treeData: tree, currentNode: node}); //tree
|
this.setState({ treeData: tree, currentNode: node }); //tree
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -312,12 +317,12 @@ class Wiki extends Component {
|
|||||||
treeData: tree
|
treeData: tree
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({isLoadFailed: true});
|
this.setState({ isLoadFailed: true });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
removePythonWrapper = () => {
|
removePythonWrapper = () => {
|
||||||
if (this.pythonWrapper) {
|
if (this.pythonWrapper) {
|
||||||
document.body.removeChild(this.pythonWrapper);
|
document.body.removeChild(this.pythonWrapper);
|
||||||
this.pythonWrapper = null;
|
this.pythonWrapper = null;
|
||||||
}
|
}
|
||||||
@@ -391,7 +396,7 @@ class Wiki extends Component {
|
|||||||
let tree = this.state.treeData.clone();
|
let tree = this.state.treeData.clone();
|
||||||
let node = tree.getNodeByPath(item.path);
|
let node = tree.getNodeByPath(item.path);
|
||||||
treeHelper.expandNode(node);
|
treeHelper.expandNode(node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
} else {
|
} else {
|
||||||
this.loadNodeAndParentsByPath(path);
|
this.loadNodeAndParentsByPath(path);
|
||||||
}
|
}
|
||||||
@@ -411,14 +416,14 @@ class Wiki extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMenuClick = () => {
|
onMenuClick = () => {
|
||||||
this.setState({closeSideBar: !this.state.closeSideBar});
|
this.setState({ closeSideBar: !this.state.closeSideBar });
|
||||||
};
|
};
|
||||||
|
|
||||||
onMainNavBarClick = (nodePath) => {
|
onMainNavBarClick = (nodePath) => {
|
||||||
let tree = this.state.treeData.clone();
|
let tree = this.state.treeData.clone();
|
||||||
let node = tree.getNodeByPath(nodePath);
|
let node = tree.getNodeByPath(nodePath);
|
||||||
tree.expandNode(node);
|
tree.expandNode(node);
|
||||||
this.setState({treeData: tree, currentNode: node});
|
this.setState({ treeData: tree, currentNode: node });
|
||||||
this.showDir(node.path);
|
this.showDir(node.path);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -431,7 +436,7 @@ class Wiki extends Component {
|
|||||||
if (Utils.isMarkdownFile(direntPath)) {
|
if (Utils.isMarkdownFile(direntPath)) {
|
||||||
this.showFile(direntPath);
|
this.showFile(direntPath);
|
||||||
} else {
|
} else {
|
||||||
const w=window.open('about:blank');
|
const w = window.open('about:blank');
|
||||||
const url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(direntPath);
|
const url = siteRoot + 'd/' + sharedToken + '/files/?p=' + Utils.encodePath(direntPath);
|
||||||
w.location.href = url;
|
w.location.href = url;
|
||||||
}
|
}
|
||||||
@@ -439,12 +444,12 @@ class Wiki extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onCloseSide = () => {
|
onCloseSide = () => {
|
||||||
this.setState({closeSideBar: !this.state.closeSideBar});
|
this.setState({ closeSideBar: !this.state.closeSideBar });
|
||||||
};
|
};
|
||||||
|
|
||||||
onNodeClick = (node) => {
|
onNodeClick = (node) => {
|
||||||
if (!this.state.pathExist) {
|
if (!this.state.pathExist) {
|
||||||
this.setState({pathExist: true});
|
this.setState({ pathExist: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.object.isDir()) {
|
if (node.object.isDir()) {
|
||||||
@@ -454,23 +459,23 @@ class Wiki extends Component {
|
|||||||
wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
|
wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
|
||||||
this.addResponseListToNode(res.data.dirent_list, node);
|
this.addResponseListToNode(res.data.dirent_list, node);
|
||||||
tree.collapseNode(node);
|
tree.collapseNode(node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (node.path === this.state.path) {
|
if (node.path === this.state.path) {
|
||||||
if (node.isExpanded) {
|
if (node.isExpanded) {
|
||||||
let tree = treeHelper.collapseNode(this.state.treeData, node);
|
let tree = treeHelper.collapseNode(this.state.treeData, node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
} else {
|
} else {
|
||||||
let tree = this.state.treeData.clone();
|
let tree = this.state.treeData.clone();
|
||||||
node = tree.getNodeByPath(node.path);
|
node = tree.getNodeByPath(node.path);
|
||||||
tree.expandNode(node);
|
tree.expandNode(node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.path === this.state.path ) {
|
if (node.path === this.state.path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +497,7 @@ class Wiki extends Component {
|
|||||||
|
|
||||||
onNodeCollapse = (node) => {
|
onNodeCollapse = (node) => {
|
||||||
let tree = treeHelper.collapseNode(this.state.treeData, node);
|
let tree = treeHelper.collapseNode(this.state.treeData, node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
};
|
};
|
||||||
|
|
||||||
onNodeExpanded = (node) => {
|
onNodeExpanded = (node) => {
|
||||||
@@ -501,11 +506,11 @@ class Wiki extends Component {
|
|||||||
if (!node.isLoaded) {
|
if (!node.isLoaded) {
|
||||||
wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
|
wikiAPI.listWiki2Dir(wikiId, node.path).then(res => {
|
||||||
this.addResponseListToNode(res.data.dirent_list, node);
|
this.addResponseListToNode(res.data.dirent_list, node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
tree.expandNode(node);
|
tree.expandNode(node);
|
||||||
this.setState({treeData: tree});
|
this.setState({ treeData: tree });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -525,7 +530,7 @@ class Wiki extends Component {
|
|||||||
direntList = Utils.sortDirents(direntList, 'name', 'asc');
|
direntList = Utils.sortDirents(direntList, 'name', 'asc');
|
||||||
|
|
||||||
let nodeList = direntList.map(object => {
|
let nodeList = direntList.map(object => {
|
||||||
return new TreeNode({object});
|
return new TreeNode({ object });
|
||||||
});
|
});
|
||||||
node.addChildren(nodeList);
|
node.addChildren(nodeList);
|
||||||
};
|
};
|
||||||
@@ -539,7 +544,7 @@ class Wiki extends Component {
|
|||||||
direntList = Utils.sortDirents(direntList, 'name', 'asc');
|
direntList = Utils.sortDirents(direntList, 'name', 'asc');
|
||||||
|
|
||||||
let nodeList = direntList.map(object => {
|
let nodeList = direntList.map(object => {
|
||||||
return new TreeNode({object});
|
return new TreeNode({ object });
|
||||||
});
|
});
|
||||||
node.addChildren(nodeList);
|
node.addChildren(nodeList);
|
||||||
};
|
};
|
||||||
@@ -598,7 +603,7 @@ class Wiki extends Component {
|
|||||||
setCurrentPage={this.setCurrentPage}
|
setCurrentPage={this.setCurrentPage}
|
||||||
currentPageId={this.state.currentPageId}
|
currentPageId={this.state.currentPageId}
|
||||||
/>
|
/>
|
||||||
<MainPanel
|
{<MainPanel
|
||||||
path={this.state.path}
|
path={this.state.path}
|
||||||
pathExist={this.state.pathExist}
|
pathExist={this.state.pathExist}
|
||||||
isViewFile={this.state.isViewFile}
|
isViewFile={this.state.isViewFile}
|
||||||
@@ -611,7 +616,9 @@ class Wiki extends Component {
|
|||||||
onMenuClick={this.onMenuClick}
|
onMenuClick={this.onMenuClick}
|
||||||
onSearchedClick={this.onSearchedClick}
|
onSearchedClick={this.onSearchedClick}
|
||||||
onMainNavBarClick={this.onMainNavBarClick}
|
onMainNavBarClick={this.onMainNavBarClick}
|
||||||
/>
|
can_edit_file={this.state.can_edit_file}
|
||||||
|
seadoc_access_token={this.state.seadoc_access_token}
|
||||||
|
/>}
|
||||||
<MediaQuery query="(max-width: 767.8px)">
|
<MediaQuery query="(max-width: 767.8px)">
|
||||||
<Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal>
|
<Modal isOpen={!this.state.closeSideBar} toggle={this.onCloseSide} contentClassName="d-none"></Modal>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { WikiViewer } from '@seafile/sdoc-editor';
|
||||||
import { gettext, repoID, siteRoot, username, isEditWiki } from '../../utils/constants';
|
import { gettext, repoID, siteRoot, username, isEditWiki } from '../../utils/constants';
|
||||||
import SeafileMarkdownViewer from '../../components/seafile-markdown-viewer';
|
import SeafileMarkdownViewer from '../../components/seafile-markdown-viewer';
|
||||||
import Loading from '../../components/loading';
|
import Loading from '../../components/loading';
|
||||||
@@ -22,10 +23,20 @@ const propTypes = {
|
|||||||
onSearchedClick: PropTypes.func.isRequired,
|
onSearchedClick: PropTypes.func.isRequired,
|
||||||
onMainNavBarClick: PropTypes.func.isRequired,
|
onMainNavBarClick: PropTypes.func.isRequired,
|
||||||
onLinkClick: PropTypes.func.isRequired,
|
onLinkClick: PropTypes.func.isRequired,
|
||||||
|
can_edit_file: PropTypes.bool,
|
||||||
|
seadoc_access_token: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
class MainPanel extends Component {
|
class MainPanel extends Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
docUuid: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
onMenuClick = () => {
|
onMenuClick = () => {
|
||||||
this.props.onMenuClick();
|
this.props.onMenuClick();
|
||||||
};
|
};
|
||||||
@@ -73,19 +84,42 @@ class MainPanel extends Component {
|
|||||||
return pathElem;
|
return pathElem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static getDerivedStateFromProps(props, state) {
|
||||||
|
const { can_edit_file, seadoc_access_token } = props;
|
||||||
|
const config = window.app.config;
|
||||||
|
const pageOptions = window.app.pageOptions;
|
||||||
|
const { assetsUrl, seadocServerUrl: sdocServer, } = window.wiki.config;
|
||||||
|
window.seafile = {
|
||||||
|
...window.seafile, // need docUuid
|
||||||
|
...config,
|
||||||
|
...pageOptions,
|
||||||
|
sdocServer,
|
||||||
|
assetsUrl,
|
||||||
|
can_edit_file,
|
||||||
|
accessToken: seadoc_access_token,
|
||||||
|
serviceUrl: config.serviceURL,
|
||||||
|
};
|
||||||
|
return { ...props, docUuid: window.seafile.docUuid };
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// let { onSearchedClick } = this.props;
|
|
||||||
const errMessage = (<div className="message err-tip">{gettext('Folder does not exist.')}</div>);
|
const errMessage = (<div className="message err-tip">{gettext('Folder does not exist.')}</div>);
|
||||||
const isViewingFile = this.props.pathExist && !this.props.isDataLoading && this.props.isViewFile;
|
const isViewingFile = this.props.pathExist && !this.props.isDataLoading && this.props.isViewFile;
|
||||||
|
const { content } = this.props;
|
||||||
|
const editorContent = content && JSON.parse(content);
|
||||||
return (
|
return (
|
||||||
<div className="main-panel wiki-main-panel" style={{flex: isEditWiki ? '1 0 76%' : '1 0 80%'}}>
|
<div className="main-panel wiki-main-panel" style={{ flex: isEditWiki ? '1 0 76%' : '1 0 80%' }}>
|
||||||
<div className="main-panel-hide hide">{this.props.content}</div>
|
<div className="main-panel-hide hide">{this.props.content}</div>
|
||||||
<div className={`main-panel-north panel-top ${this.props.permission === 'rw' ? 'border-left-show' : ''}`}>
|
<div className={`main-panel-north panel-top ${this.props.permission === 'rw' ? 'border-left-show' : ''}`}>
|
||||||
{!username &&
|
{!username &&
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="cur-view-toolbar">
|
<div className="cur-view-toolbar">
|
||||||
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
|
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
|
||||||
|
{this.props.permission == 'rw' && (
|
||||||
|
Utils.isDesktop() ?
|
||||||
|
<button className="btn btn-secondary operation-item" title={gettext('Edit')} onClick={this.onEditClick}>{gettext('Edit')}</button> :
|
||||||
|
<span className="fa fa-pencil-alt mobile-toolbar-icon" title={gettext('Edit')} onClick={this.onEditClick} style={{ 'fontSize': '1.1rem' }}></span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="common-toolbar">
|
<div className="common-toolbar">
|
||||||
{/* {isPro && (
|
{/* {isPro && (
|
||||||
@@ -98,11 +132,6 @@ class MainPanel extends Component {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<div className="cur-view-toolbar">
|
<div className="cur-view-toolbar">
|
||||||
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
|
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
|
||||||
{this.props.permission == 'rw' && (
|
|
||||||
Utils.isDesktop() ?
|
|
||||||
<button className="btn btn-secondary operation-item" title={gettext('Edit')} onClick={this.onEditClick}>{gettext('Edit')}</button> :
|
|
||||||
<span className="fa fa-pencil-alt mobile-toolbar-icon" title={gettext('Edit')} onClick={this.onEditClick} style={{'fontSize': '1.1rem'}}></span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="common-toolbar">
|
<div className="common-toolbar">
|
||||||
{/* {isPro && (
|
{/* {isPro && (
|
||||||
@@ -123,23 +152,19 @@ class MainPanel extends Component {
|
|||||||
isWiki={true}
|
isWiki={true}
|
||||||
path={this.props.path}
|
path={this.props.path}
|
||||||
repoID={repoID}
|
repoID={repoID}
|
||||||
markdownContent={this.props.content}
|
markdownContent={content}
|
||||||
isFileLoading={this.props.isDataLoading}
|
isFileLoading={this.props.isDataLoading}
|
||||||
lastModified = {this.props.lastModified}
|
lastModified={this.props.lastModified}
|
||||||
latestContributor={this.props.latestContributor}
|
latestContributor={this.props.latestContributor}
|
||||||
onLinkClick={this.props.onLinkClick}
|
onLinkClick={this.props.onLinkClick}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isViewingFile && Utils.isSdocFile(this.props.path) && (
|
{this.props.seadoc_access_token && this.state.docUuid && isViewingFile && Utils.isSdocFile(this.props.path) && (
|
||||||
<SdocWikiPageViewer
|
<WikiViewer
|
||||||
isWiki={true}
|
document={editorContent}
|
||||||
path={this.props.path}
|
showOutline={false}
|
||||||
repoID={repoID}
|
showToolbar={false}
|
||||||
markdownContent={this.props.content}
|
docUuid={this.state.docUuid}
|
||||||
isFileLoading={this.props.isDataLoading}
|
|
||||||
lastModified = {this.props.lastModified}
|
|
||||||
latestContributor={this.props.latestContributor}
|
|
||||||
onLinkClick={this.props.onLinkClick}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -3,5 +3,7 @@ export default class Page {
|
|||||||
this.id = object.id;
|
this.id = object.id;
|
||||||
this.name = object.name;
|
this.name = object.name;
|
||||||
this.path = object.path;
|
this.path = object.path;
|
||||||
|
this.icon = object.icon;
|
||||||
|
this.docUuid = object.docUuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ class SidePanel extends Component {
|
|||||||
renderIndexView = () => {
|
renderIndexView = () => {
|
||||||
return (
|
return (
|
||||||
<div className="wiki-pages-container">
|
<div className="wiki-pages-container">
|
||||||
<div style={{marginTop: '2px'}}></div>
|
<div style={{ marginTop: '2px' }}></div>
|
||||||
<IndexMdViewer
|
<IndexMdViewer
|
||||||
indexContent={this.props.indexContent}
|
indexContent={this.props.indexContent}
|
||||||
onLinkClick={this.props.onLinkClick}
|
onLinkClick={this.props.onLinkClick}
|
||||||
@@ -115,11 +115,11 @@ class SidePanel extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onAddNewPage = async ({name, icon, path, successCallback, errorCallback}) => {
|
onAddNewPage = async ({ name, icon, path, docUuid,successCallback, errorCallback }) => {
|
||||||
const { config } = this.props;
|
const { config } = this.props;
|
||||||
const navigation = config.navigation;
|
const navigation = config.navigation;
|
||||||
const pageId = generateUniqueId(navigation);
|
const pageId = generateUniqueId(navigation);
|
||||||
const newPage = new Page({ id: pageId, name, icon, path});
|
const newPage = new Page({ id: pageId, name, icon, path,docUuid });
|
||||||
this.addPage(newPage, successCallback, errorCallback);
|
this.addPage(newPage, successCallback, errorCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -392,12 +392,12 @@ class SidePanel extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={`side-panel wiki-side-panel ${this.props.closeSideBar ? '': 'left-zero'}`}>
|
<div className={`side-panel wiki-side-panel ${this.props.closeSideBar ? '' : 'left-zero'}`}>
|
||||||
<div className="side-panel-top panel-top">
|
<div className="side-panel-top panel-top">
|
||||||
<h4 className="ml-0 mb-0 text-truncate" title={repoName}>{repoName}</h4>
|
<h4 className="ml-0 mb-0 text-truncate" title={repoName}>{repoName}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="side-nav" className="wiki-side-nav" role="navigation">
|
<div id="side-nav" className="wiki-side-nav" role="navigation">
|
||||||
{this.renderContent() }
|
{this.renderContent()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -95,11 +95,12 @@ class AddNewPageDialog extends React.Component {
|
|||||||
|
|
||||||
createFile = (pageName, filePath) => {
|
createFile = (pageName, filePath) => {
|
||||||
seafileAPI.createFile(repoID, filePath).then(res => {
|
seafileAPI.createFile(repoID, filePath).then(res => {
|
||||||
const { obj_name, parent_dir } = res.data;
|
const { obj_name, parent_dir,doc_uuid } = res.data;
|
||||||
this.props.onAddNewPage({
|
this.props.onAddNewPage({
|
||||||
name: pageName,
|
name: pageName,
|
||||||
icon: '',
|
icon: '',
|
||||||
path: parent_dir === '/' ? `/${obj_name}` : `${parent_dir}/${obj_name}`,
|
path: parent_dir === '/' ? `/${obj_name}` : `${parent_dir}/${obj_name}`,
|
||||||
|
docUuid:doc_uuid,
|
||||||
successCallback: this.onSuccess,
|
successCallback: this.onSuccess,
|
||||||
errorCallback: this.onError,
|
errorCallback: this.onError,
|
||||||
});
|
});
|
||||||
@@ -135,7 +136,7 @@ class AddNewPageDialog extends React.Component {
|
|||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
||||||
{this.state.isLoading ?
|
{this.state.isLoading ?
|
||||||
<Button color="primary" disabled><Loading/></Button> :
|
<Button color="primary" disabled><Loading /></Button> :
|
||||||
<Button color="primary" onClick={this.onSubmit}>{gettext('Submit')}</Button>
|
<Button color="primary" onClick={this.onSubmit}>{gettext('Submit')}</Button>
|
||||||
}
|
}
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
|
@@ -193,6 +193,10 @@ class ViewItem extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setDocUuid = (docUuid) => {
|
||||||
|
window.seafile['docUuid'] = docUuid;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
connectDragSource, connectDragPreview, connectDropTarget, isOver, canDrop, isDragging,
|
connectDragSource, connectDragPreview, connectDropTarget, isOver, canDrop, isDragging,
|
||||||
@@ -200,7 +204,7 @@ class ViewItem extends Component {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
const { isShowViewEditor, viewName, viewIcon, isSelected } = this.state;
|
const { isShowViewEditor, viewName, viewIcon, isSelected } = this.state;
|
||||||
const isOverView = isOver && canDrop;
|
const isOverView = isOver && canDrop;
|
||||||
|
if (isSelected) this.setDocUuid(view.docUuid);
|
||||||
const isSpecialInstance = false;
|
const isSpecialInstance = false;
|
||||||
|
|
||||||
let viewCanDropTop;
|
let viewCanDropTop;
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
.wiki-pages-container .tree-view {
|
.wiki-pages-container .tree-view {
|
||||||
margin-left: -10px;
|
margin-left: -10px;
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
padding-left:0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
img[src=""] {
|
img[src=""] {
|
||||||
@@ -86,6 +86,10 @@ img[src=""] {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main-panel-center .cur-view-content {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.cur-view-content .wiki-page-content {
|
.cur-view-content .wiki-page-content {
|
||||||
width: calc(100% - 200px);
|
width: calc(100% - 200px);
|
||||||
padding-right: 30px;
|
padding-right: 30px;
|
||||||
@@ -96,6 +100,7 @@ img[src=""] {
|
|||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
padding-top: 30px;
|
padding-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cur-view-content .wiki-page-content {
|
.cur-view-content .wiki-page-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
@@ -116,7 +121,7 @@ img[src=""] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.wiki-page-container .outline-h2.active,
|
.wiki-page-container .outline-h2.active,
|
||||||
.wiki-page-container .outline-h3.active {
|
.wiki-page-container .outline-h3.active {
|
||||||
color: #eb8205;
|
color: #eb8205;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,3 +146,124 @@ img[src=""] {
|
|||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* wiki editor */
|
||||||
|
.sdoc-editor-container {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
min-height: 0;
|
||||||
|
/* background-color: hotpink; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-wiki-scroll-container {
|
||||||
|
display: flex;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-wiki-scroll-container .sdoc-article-container {
|
||||||
|
padding-left: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-wiki-scroll-container .sdoc-article-container .article .sdoc-header-2 {
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-wiki-outline-container {
|
||||||
|
height: 80%;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 1rem;
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
top: 97px;
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-editor-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 20px;
|
||||||
|
height: 56px;
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
background-color: #fff;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-editor-header .doc-ops {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container {
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container .side-file-bar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 280px;
|
||||||
|
border-right: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container .side-file-bar {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container .side-file-bar .wiki-go-lib {}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container .side-file-bar .file-list .file-item {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .wiki-viewer-container .side-file-bar .file-list .file-item.active {
|
||||||
|
background-color: #e5e5e5;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki-editor .sdoc-wiki-outline-container {
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wiki editor style */
|
||||||
|
.sdoc-editor-container .article :first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-editor-container .article {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 800px;
|
||||||
|
padding: 40px 40px 40px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-editor-container .article>div {
|
||||||
|
caret-color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-editor-container .article .sdoc-drag-cover::before {
|
||||||
|
content: ' ';
|
||||||
|
width: 59px;
|
||||||
|
display: inline-block;
|
||||||
|
position: absolute;
|
||||||
|
left: -60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-editor-container .article .sdoc-draging {
|
||||||
|
border-bottom: 2px solid rgba(35, 131, 226);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sdoc-editor-container {
|
||||||
|
display: flex;
|
||||||
|
/* position: absolute; */
|
||||||
|
min-width: 1100px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user