mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +00:00
12.0 change wiki style (#6152)
* 01 change delete Wiki tip * 02 remove modify time when wiki init
This commit is contained in:
@@ -6,28 +6,24 @@ import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
toggleCancel: PropTypes.func.isRequired,
|
toggleCancel: PropTypes.func.isRequired,
|
||||||
handleSubmit: PropTypes.func.isRequired,
|
handleSubmit: PropTypes.func.isRequired,
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
content: PropTypes.string.isRequired,
|
||||||
|
footer: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class WikiDeleteDialog extends React.Component {
|
function WikiDeleteDialog({ handleSubmit, toggleCancel, title, content, footer }) {
|
||||||
|
|
||||||
toggle = () => {
|
|
||||||
this.props.toggleCancel();
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={true} toggle={this.toggle}>
|
<Modal isOpen={true} toggle={toggleCancel}>
|
||||||
<ModalHeader toggle={this.toggle}>{gettext('Unpublish Library')}</ModalHeader>
|
<ModalHeader toggle={toggleCancel}>{title}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<p>{gettext('Are you sure you want to unpublish this library?')}</p>
|
<p>{content}</p>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={toggleCancel}>{gettext('Cancel')}</Button>
|
||||||
<Button color="primary" onClick={this.props.handleSubmit}>{gettext('Unpublish')}</Button>
|
<Button color="primary" onClick={handleSubmit}>{footer}</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WikiDeleteDialog.propTypes = propTypes;
|
WikiDeleteDialog.propTypes = propTypes;
|
||||||
|
@@ -134,7 +134,11 @@ class WikiCardItem extends Component {
|
|||||||
/>
|
/>
|
||||||
<DropdownMenu right={true} className="dtable-dropdown-menu">
|
<DropdownMenu right={true} className="dtable-dropdown-menu">
|
||||||
<DropdownItem onClick={this.onRenameToggle}>{gettext('Rename')}</DropdownItem>
|
<DropdownItem onClick={this.onRenameToggle}>{gettext('Rename')}</DropdownItem>
|
||||||
|
{isOldVersion ?
|
||||||
<DropdownItem onClick={this.onDeleteToggle}>{gettext('Unpublish')}</DropdownItem>
|
<DropdownItem onClick={this.onDeleteToggle}>{gettext('Unpublish')}</DropdownItem>
|
||||||
|
:
|
||||||
|
<DropdownItem onClick={this.onDeleteToggle}>{gettext('Delete')}</DropdownItem>
|
||||||
|
}
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
@@ -145,10 +149,23 @@ class WikiCardItem extends Component {
|
|||||||
</div>
|
</div>
|
||||||
{this.state.isShowDeleteDialog &&
|
{this.state.isShowDeleteDialog &&
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
|
{isOldVersion ?
|
||||||
<WikiDeleteDialog
|
<WikiDeleteDialog
|
||||||
toggleCancel={this.onDeleteCancel}
|
toggleCancel={this.onDeleteCancel}
|
||||||
handleSubmit={this.deleteWiki}
|
handleSubmit={this.deleteWiki}
|
||||||
|
title={gettext('Unpublish Wiki')}
|
||||||
|
content={gettext('Are you sure you want to unpublish this Wiki?')}
|
||||||
|
footer={gettext('Unpublish')}
|
||||||
/>
|
/>
|
||||||
|
:
|
||||||
|
<WikiDeleteDialog
|
||||||
|
toggleCancel={this.onDeleteCancel}
|
||||||
|
handleSubmit={this.deleteWiki}
|
||||||
|
title={gettext('Delete Wiki')}
|
||||||
|
content={gettext('Are you sure you want to delete this Wiki?')}
|
||||||
|
footer={gettext('Delete')}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</ModalPortal>
|
</ModalPortal>
|
||||||
}
|
}
|
||||||
{this.state.isShowRenameDialog &&
|
{this.state.isShowRenameDialog &&
|
||||||
|
@@ -38,8 +38,6 @@ class Wiki extends Component {
|
|||||||
seadoc_access_token: '',
|
seadoc_access_token: '',
|
||||||
assets_url: '',
|
assets_url: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pythonWrapper = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UNSAFE_componentWillMount() {
|
UNSAFE_componentWillMount() {
|
||||||
@@ -123,13 +121,6 @@ class Wiki extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
removePythonWrapper = () => {
|
|
||||||
if (this.pythonWrapper) {
|
|
||||||
document.body.removeChild(this.pythonWrapper);
|
|
||||||
this.pythonWrapper = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onCloseSide = () => {
|
onCloseSide = () => {
|
||||||
this.setState({ closeSideBar: !this.state.closeSideBar });
|
this.setState({ closeSideBar: !this.state.closeSideBar });
|
||||||
};
|
};
|
||||||
@@ -138,8 +129,6 @@ class Wiki extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
isDataLoading: true,
|
isDataLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.removePythonWrapper();
|
|
||||||
wikiAPI.getWiki2Page(wikiId, pageId).then(res => {
|
wikiAPI.getWiki2Page(wikiId, pageId).then(res => {
|
||||||
const { permission, seadoc_access_token, assets_url } = res.data;
|
const { permission, seadoc_access_token, assets_url } = res.data;
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="wrapper" class="{{ LANGUAGE_CODE }}"></div>
|
<div id="wrapper" class="{{ LANGUAGE_CODE }}"></div>
|
||||||
<div id="modal-wrapper" class="{{ LANGUAGE_CODE }}"></div>
|
<div id="modal-wrapper" class="{{ LANGUAGE_CODE }}"></div>
|
||||||
{%block extra_content %}{% endblock %}
|
{% block wiki-v1-extra_content %}{% endblock %}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.app = {
|
window.app = {
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
{% block wiki_title %} {{h1_head_content}} - {{repo_name}}{% endblock %}
|
{% block wiki_title %} {{h1_head_content}} - {{repo_name}}{% endblock %}
|
||||||
|
|
||||||
{% block extra_content %}
|
{% block wiki-v1-extra_content %}
|
||||||
{% if not is_dir %}
|
{% if not is_dir %}
|
||||||
<div id="wiki-file-content" class="{{ LANGUAGE_CODE }}">
|
<div id="wiki-file-content" class="{{ LANGUAGE_CODE }}">
|
||||||
<div class="article">
|
<div class="article">
|
||||||
|
@@ -18,26 +18,6 @@
|
|||||||
|
|
||||||
{% block wiki_title %} {{h1_head_content}} - {{repo_name}}{% endblock %}
|
{% block wiki_title %} {{h1_head_content}} - {{repo_name}}{% endblock %}
|
||||||
|
|
||||||
{% block extra_content %}
|
|
||||||
{% if not is_dir %}
|
|
||||||
<div id="wiki-file-content" class="{{ LANGUAGE_CODE }}">
|
|
||||||
<div class="article">
|
|
||||||
{{ file_content }}
|
|
||||||
<p id="wiki-page-last-modified">{% translate "Last modified by" %} {{modifier|email2nickname}},
|
|
||||||
<span>{{modify_time|translate_seahub_time_str}}</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="seafile-markdown-outline">
|
|
||||||
<div id="seafile-editor-outline" class="seafile-editor-outline">
|
|
||||||
{% for outline in outlines %}
|
|
||||||
{{ outline }}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.wiki = {
|
window.wiki = {
|
||||||
@@ -52,74 +32,5 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript">
|
|
||||||
// titles info
|
|
||||||
let titlesInfo = [];
|
|
||||||
let headingList = document.querySelectorAll('h2[id^="user-content"], h3[id^="user-content"]');
|
|
||||||
for (let i = 0; i < headingList.length; i++) {
|
|
||||||
titlesInfo.push(headingList[i].offsetTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
// outline infos
|
|
||||||
const outlineInfos = document.querySelectorAll('.outline-h2, .outline-h3');
|
|
||||||
const addActiveClass = (item) => {
|
|
||||||
const className = item.className;
|
|
||||||
if (className.indexOf('active') > -1) return;
|
|
||||||
item.className += ' active';
|
|
||||||
};
|
|
||||||
const removeActiveClass = (item) => {
|
|
||||||
const className = item.className;
|
|
||||||
if (className.indexOf('active') === -1) return;
|
|
||||||
item.className = className.replace(/(?:^|\s)active(?!\S)/g, '');
|
|
||||||
};
|
|
||||||
const updateOutline = (activeIndex) => {
|
|
||||||
for (let i = 0; i < outlineInfos.length; i++) {
|
|
||||||
const item = outlineInfos[i];
|
|
||||||
if (activeIndex !== i) {
|
|
||||||
removeActiveClass(item);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
addActiveClass(item);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const outlineContainer = document.getElementById('seafile-editor-outline');
|
|
||||||
outlineContainer && outlineContainer.addEventListener('click', (event) => {
|
|
||||||
const text = event.target.innerText;
|
|
||||||
let url = new URL(window.location.href);
|
|
||||||
url.hash = '#user-content-' + text;
|
|
||||||
window.location.href = url.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
// scroll event handle
|
|
||||||
const container = document.getElementById('wiki-file-content');
|
|
||||||
if (container) {
|
|
||||||
container.style.left = '24%';
|
|
||||||
}
|
|
||||||
container && container.addEventListener('scroll', () => {
|
|
||||||
const titlesLength = titlesInfo.length;
|
|
||||||
const contentScrollTop = container.scrollTop + 180;
|
|
||||||
let activeTitleIndex;
|
|
||||||
if (contentScrollTop <= titlesInfo[0]) {
|
|
||||||
activeTitleIndex = 0;
|
|
||||||
} else if (contentScrollTop > titlesInfo[titlesLength - 1]) {
|
|
||||||
activeTitleIndex = titlesInfo.length - 1;
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < titlesLength; i++) {
|
|
||||||
if (contentScrollTop > titlesInfo[i]) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
activeTitleIndex = i - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOutline(activeTitleIndex);
|
|
||||||
});
|
|
||||||
|
|
||||||
// set first outline to active
|
|
||||||
updateOutline(0);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% render_bundle 'wiki2' 'js' %}
|
{% render_bundle 'wiki2' 'js' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Reference in New Issue
Block a user