mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-14 15:35:35 +00:00
Merge pull request #5190 from haiwen/repair-wiki-markdown-viewer
repair refresh page scroll bug
This commit is contained in:
commit
05064ff72b
@ -39,6 +39,8 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
this.links.forEach(link => {
|
this.links.forEach(link => {
|
||||||
link.addEventListener('click', this.onLinkClick);
|
link.addEventListener('click', this.onLinkClick);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.getTitlesInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
@ -57,6 +59,9 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
this.links.forEach(link => {
|
this.links.forEach(link => {
|
||||||
link.addEventListener('click', this.onLinkClick);
|
link.addEventListener('click', this.onLinkClick);
|
||||||
});
|
});
|
||||||
|
if (this.titlesInfo.length === 0) {
|
||||||
|
this.getTitlesInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -66,8 +71,13 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentRendered = (markdownViewer) => {
|
getTitlesInfo = () => {
|
||||||
this.titlesInfo = markdownViewer.titlesInfo;
|
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);
|
||||||
|
}
|
||||||
|
this.titlesInfo = titlesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLinkClick = (event) => {
|
onLinkClick = (event) => {
|
||||||
@ -170,7 +180,6 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
scriptSource={mediaUrl + 'js/mathjax/tex-svg.js'}
|
scriptSource={mediaUrl + 'js/mathjax/tex-svg.js'}
|
||||||
markdownContent={this.props.markdownContent}
|
markdownContent={this.props.markdownContent}
|
||||||
activeTitleIndex={this.state.activeTitleIndex}
|
activeTitleIndex={this.state.activeTitleIndex}
|
||||||
onContentRendered={this.onContentRendered}
|
|
||||||
modifyValueBeforeRender={this.modifyValueBeforeRender}
|
modifyValueBeforeRender={this.modifyValueBeforeRender}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -182,7 +191,6 @@ class WikiMarkdownViewer extends React.Component {
|
|||||||
scriptSource={mediaUrl + 'js/mathjax/tex-svg.js'}
|
scriptSource={mediaUrl + 'js/mathjax/tex-svg.js'}
|
||||||
markdownContent={this.props.markdownContent}
|
markdownContent={this.props.markdownContent}
|
||||||
activeTitleIndex={this.state.activeTitleIndex}
|
activeTitleIndex={this.state.activeTitleIndex}
|
||||||
onContentRendered={this.onContentRendered}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user