mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-29 04:01:24 +00:00
Chapter jump (#2307)
This commit is contained in:
parent
61f0c49cd4
commit
0815a90a90
@ -44,19 +44,15 @@ class MarkdownViewerContent extends React.Component {
|
||||
|
||||
class MarkdownViewer extends React.Component {
|
||||
|
||||
state = {
|
||||
renderingContent: true,
|
||||
renderingOutline: true,
|
||||
html: '',
|
||||
outlineTreeRoot: null,
|
||||
navItems: [],
|
||||
activeId: 0
|
||||
}
|
||||
|
||||
scrollToNode(node) {
|
||||
let url = new URL(window.location.href);
|
||||
url.set('hash', 'user-content-' + node.data.id);
|
||||
window.location.href = url.toString();
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
renderingContent: true,
|
||||
html: '',
|
||||
navItems: [],
|
||||
activeId: 0,
|
||||
};
|
||||
this.activeIdFromOutLine = null;
|
||||
}
|
||||
|
||||
scrollHandler = (event) => {
|
||||
@ -93,6 +89,14 @@ class MarkdownViewer extends React.Component {
|
||||
html: String(file),
|
||||
renderingContent: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
// reset the href to jump to the section
|
||||
var url = new URL(window.location.href);
|
||||
if (url.hash) {
|
||||
window.location.href = window.location.href;
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,9 @@ class Wiki extends Component {
|
||||
})
|
||||
})
|
||||
|
||||
let fileUrl = serviceUrl + '/wikis/' + slug + filePath;
|
||||
window.history.pushState({urlPath: fileUrl, filePath: filePath}, filePath, fileUrl);
|
||||
const hash = window.location.hash;
|
||||
let fileUrl = serviceUrl + '/wikis/' + slug + filePath + hash;
|
||||
window.history.pushState({urlPath: fileUrl, filePath: filePath}, filePath, fileUrl);
|
||||
}
|
||||
|
||||
onpopstate = (event) => {
|
||||
|
Loading…
Reference in New Issue
Block a user