forked from mirror/MrDoc
优化HTML模板文件
This commit is contained in:
parent
9a97d8e2ac
commit
c62247a3f1
File diff suppressed because one or more lines are too long
@ -210,7 +210,7 @@
|
||||
}
|
||||
// 切换文档目录显示与否
|
||||
$(".tocMenu").click(function() {
|
||||
console.log("切换文档目录显示")
|
||||
// console.log("切换文档目录显示")
|
||||
$(".sidebar").toggleClass("doc-toc-hide");
|
||||
});
|
||||
|
||||
|
@ -300,20 +300,23 @@
|
||||
<p><a href="https://zmister.com" target="_blank">作者博客:https://zmister.com</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{% static 'jquery/3.1.1/jquery.min.js' %}"></script>
|
||||
<script src="{% static 'layui/layui.all.js' %}"></script>
|
||||
<script>
|
||||
var layer = layui.layer;
|
||||
</script>
|
||||
<script src="{% static 'viewerjs/viewer.min.js' %}"></script>
|
||||
<script src="{% static 'qrcodejs/qrcode.min.js' %}"></script>
|
||||
<script src="{% static 'mrdoc/mrdoc-docs.js' %}?version={{mrdoc_version}}"></script>
|
||||
<script src="{% static 'iconFont/iconfont.js' %}"></script>
|
||||
<script>
|
||||
{% if toc_cnt > 999 %}
|
||||
// 如果文集的文档数量大于999,使用异步加载左侧文集大纲
|
||||
getProjectToc();
|
||||
{% endif %}
|
||||
{% if toc_cnt > 999 %}
|
||||
// 如果文集的文档数量大于999,使用异步加载左侧文集大纲
|
||||
getProjectToc();
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
{% if doc.editor_mode == 2 %}
|
||||
@ -325,75 +328,12 @@
|
||||
|
||||
<!-- 解析渲染Markdown -->
|
||||
<script>
|
||||
{% if doc.editor_mode == 1 %}
|
||||
// EditorMD模式
|
||||
//解析Markdown为HTML
|
||||
editormd.markdownToHTML("content", {
|
||||
emoji : true, //emoji表情
|
||||
taskList : true, // 任务列表
|
||||
tex : true, // 科学公式
|
||||
flowChart : true, // 流程图
|
||||
sequenceDiagram : true, // 时序图
|
||||
tocm : true, //目录
|
||||
toc :true,
|
||||
tocContainer : "#toc-container",
|
||||
tocDropdown : false,
|
||||
atLink : false,//禁用@链接
|
||||
htmlDecode : "link,style,base,script", //过滤部分HTML标签
|
||||
});
|
||||
|
||||
{% elif doc.editor_mode == 2 %}
|
||||
// Vditor模式
|
||||
// 渲染Markdown
|
||||
// var initRender = () => {
|
||||
var md_content = $("#content textarea").val()
|
||||
Vditor.preview(document.getElementById('content'),md_content,
|
||||
{
|
||||
"cdn":"{% static 'vditor' %}",
|
||||
markdown:{
|
||||
mark:true
|
||||
},
|
||||
speech: {
|
||||
enable: true,
|
||||
},
|
||||
anchor: 1,
|
||||
after () {
|
||||
var outlineElement = document.getElementById('toc-container')
|
||||
var sub_ele = "<div class='markdown-toc editormd-markdown-toc'><ul class='markdown-toc-list'></ul></div>"
|
||||
$("#toc-container").append(sub_ele)
|
||||
var toc_elem = $("#toc-container div ul.markdown-toc-list")
|
||||
Vditor.outlineRender(document.getElementById('content'), toc_elem[0])
|
||||
if (outlineElement.innerText.trim() !== '') {
|
||||
var toc_cnt = $(".markdown-toc-list").children().length;
|
||||
//console.log(toc_cnt)
|
||||
if(toc_cnt > 0){
|
||||
//console.log('显示文档目录')
|
||||
$(".tocMenu").show();
|
||||
initSidebar('.sidebar', '.doc-content');
|
||||
}
|
||||
}else{
|
||||
console.log("无目录")
|
||||
};
|
||||
// 图片放大显示
|
||||
var img_options = {
|
||||
url: 'data-original',
|
||||
fullscreen:false,//全屏
|
||||
rotatable:false,//旋转
|
||||
scalable:false,//翻转
|
||||
button:false,//关闭按钮
|
||||
toolbar:false,
|
||||
title:false,
|
||||
};
|
||||
var img_viewer = new Viewer(document.getElementById('content'), img_options);
|
||||
},
|
||||
})
|
||||
// }
|
||||
// initRender();
|
||||
{% endif %}
|
||||
|
||||
var editor_mode = {{ doc.editor_mode }};
|
||||
var pro_id = {{doc.top_doc}};
|
||||
var doc_id = {{doc.id}};
|
||||
initDocRender(mode=editor_mode);
|
||||
{% if project.is_watermark %}
|
||||
var img_base64 = textBecomeImg('{{project.watermark_value}}','14','#000')
|
||||
document.getElementById("wm").style.background = 'url('+ img_base64 + ')'
|
||||
initWhterMark('{{project.watermark_value}}')
|
||||
{% endif %}
|
||||
</script>
|
||||
|
||||
@ -412,47 +352,17 @@
|
||||
var img_viewer = new Viewer(document.getElementById('content'), img_options);
|
||||
{% endif %}
|
||||
|
||||
// 收藏文集
|
||||
var layer = layui.layer;
|
||||
$("#collect_pro").click(function(e){
|
||||
$(this).toggleClass("layui-icon-star-fill layui-icon-star");
|
||||
$(this).toggleClass("collected");
|
||||
$.ajax({
|
||||
url:'/my_collect/',
|
||||
type:'post',
|
||||
data:{'type':2,'id':'{{project.id}}'},
|
||||
success:function(r){
|
||||
layer.msg(r.data)
|
||||
},
|
||||
error:function(){
|
||||
layer.msg("操作异常")
|
||||
}
|
||||
});
|
||||
});
|
||||
// 收藏文档
|
||||
$("#collect_doc").click(function(){
|
||||
$(this).toggleClass("layui-icon-star-fill layui-icon-star")
|
||||
$(this).toggleClass("collected")
|
||||
$.ajax({
|
||||
url:'/my_collect/',
|
||||
type:'post',
|
||||
data:{'type':1,'id':'{{doc.id}}'},
|
||||
success:function(r){
|
||||
layer.msg(r.data)
|
||||
},
|
||||
error:function(){
|
||||
layer.msg("操作异常")
|
||||
}
|
||||
})
|
||||
});
|
||||
// 外部链接添加图标
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Array.prototype.filter.call(document.links, function(link) {
|
||||
return link.hostname && link.hostname !== location.hostname;
|
||||
})
|
||||
.forEach(function(link) {
|
||||
.forEach(function(link) {
|
||||
// console.log(link,$(link).children('img').length)
|
||||
if($(link).children().length == 0){
|
||||
link.classList.add('external');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -475,6 +385,7 @@
|
||||
$("#ad-3").appendTo($("#ad-code-3"));
|
||||
</script>
|
||||
{% endif %}
|
||||
<!-- 广告代码结束 -->
|
||||
|
||||
<!-- 统计代码开始 -->
|
||||
{% if debug %}
|
||||
|
@ -219,7 +219,7 @@
|
||||
sequenceDiagram : true, //开启序列图
|
||||
imageUpload : true, //开启图片上传
|
||||
codeFold :true, //代码折叠
|
||||
htmlDecode : "link,style,base,script", //过滤部分HTML标签
|
||||
htmlDecode : "link,style,base,script|on*", //过滤部分HTML标签
|
||||
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
|
||||
imageUploadURL : "{% url 'upload_doc_img' %}",
|
||||
onchange:function(){
|
||||
|
Loading…
Reference in New Issue
Block a user