forked from Gitlink/forgeplus-react
wiki集成锚点跳转功能
This commit is contained in:
parent
7b0a6f46dd
commit
76a00475a0
|
|
@ -222,7 +222,7 @@
|
|||
"webpack": "^4.42.1",
|
||||
"webpack-bundle-analyzer": "^3.7.0"
|
||||
},
|
||||
"volta":{
|
||||
"node":"8.12.0"
|
||||
"volta": {
|
||||
"node": "8.12.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,16 @@
|
|||
$('#ie_info').css({display:'block'});
|
||||
$('#root').css({display:'none'});
|
||||
}
|
||||
</script>
|
||||
window.onload=function(){
|
||||
$(".newContainer").delegate("a.anchors","click",function(){
|
||||
let h = $(this).offset().top - 180;
|
||||
$("html,body").animate({scrollTop:h},10);
|
||||
window.location.hash = $(this).attr("name");
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
<script src="%PUBLIC_URL%js/js_min_all.js"></script>
|
||||
<script src="%PUBLIC_URL%js/codemirror/codemirror.js"></script>
|
||||
<script src="%PUBLIC_URL%js/editormd/editormd.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ export function initAxiosInterceptors(props) {
|
|||
initOnlineOfflineListener();
|
||||
|
||||
// var proxy = "http://192.168.1.40:3000";
|
||||
var proxy = "http://111.8.36.180:8000";
|
||||
// var proxy = "http://111.8.36.180:8000";
|
||||
var proxy = "http://117.50.100.12:49999"
|
||||
// var proxy = "https://www.osredm.com";
|
||||
|
||||
//响应前的设置
|
||||
|
|
|
|||
|
|
@ -155,7 +155,8 @@ renderer.heading = function (text, level, raw) {
|
|||
level: level,
|
||||
text: text
|
||||
})
|
||||
return '<h' + level + ' id="' + anchor + '">' + text + '</h' + level + '>'
|
||||
let id = anchor.replace(/[.,/#!$%^&*;:{}=\-_`~():,。¥;「」|?》《~·【】‘、!]/g,"");
|
||||
return '<h' + level + ' id="' + id + '" class="markdown_anchors"><a name="#'+id+'" class="anchors"><i class="iconfont icon-lianjieicon font-14"></i></a>' + text + '</h' + level + '>'
|
||||
}
|
||||
marked.setOptions({
|
||||
silent: true,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import React, { useEffect, useRef, useMemo } from 'react'
|
||||
import 'katex/dist/katex.min.css'
|
||||
import marked, { getTocContent, cleanToc, getMathExpressions, resetMathExpressions } from '../common/marked';
|
||||
import 'code-prettify'
|
||||
import 'code-prettify';
|
||||
import dompurify from 'dompurify';
|
||||
|
||||
import { renderToString } from 'katex'
|
||||
|
||||
const preRegex = /<pre[^>]*>/g
|
||||
const preRegex = /<pre[^>]*>/g;
|
||||
function _unescape(str) {
|
||||
let div = document.createElement('div')
|
||||
div.innerHTML = str
|
||||
|
|
@ -46,7 +46,7 @@ export default ({
|
|||
let id = decodeURIComponent(u.split("#")[1]);
|
||||
let ele = document.getElementById(id);
|
||||
if(ele){
|
||||
window.scrollTo(0, ele.offsetTop + 120);
|
||||
window.scrollTo(0, ele.offsetTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { wikiPages, getWiki, deleteWiki } from './api';
|
|||
import { httpUrl, TokenKey } from './fetch';
|
||||
import './Index.scss';
|
||||
import { isArray } from 'lodash';
|
||||
import RenderHtml from '../../components/render-html';
|
||||
const Search = Input.Search;
|
||||
const InputGroup = Input.Group;
|
||||
const { Option } = Select;
|
||||
|
|
@ -271,7 +272,7 @@ export default (props) => {
|
|||
{permission && <Button type="primary" onClick={goEdit}>编辑</Button>}
|
||||
</div>
|
||||
|
||||
<div className="wiki-content-detail editor-content-panel markdown-body" dangerouslySetInnerHTML={{ __html: itemDetail && itemDetail.simple_content }} ></div>
|
||||
{itemDetail && itemDetail.md_content && <RenderHtml className="wiki-content-detail editor-content-panel" value={ itemDetail.md_content } url={history.location}/>}
|
||||
</div>
|
||||
</div>
|
||||
</div >
|
||||
|
|
|
|||
Loading…
Reference in New Issue