优化editor.md编辑器插件加载队列和文集简介渲染

This commit is contained in:
yangjian 2021-02-03 23:07:21 +08:00
parent 70562aed84
commit f1f444a7bb
11 changed files with 8733 additions and 36 deletions

View File

@ -3901,7 +3901,8 @@
padding: 0;
}
.editormd-preview-container pre, .editormd-preview-container code, .editormd-preview-container kbd, .editormd-html-preview pre, .editormd-html-preview code, .editormd-html-preview kbd {
font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace;
/* font-family: "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; */
font-family: Consolas,PingFang SC,Tahoma,"YaHei Consolas Hybrid";
}
.editormd-preview-container table thead tr, .editormd-html-preview table thead tr {
background-color: #F8F8F8;

View File

@ -362,7 +362,6 @@
*/
init : function (id, options) {
options = options || {};
if (typeof id === "object")
@ -557,6 +556,15 @@
// _this.loadedDisplay();
});
// 加载 mindmap 相关js
editormd.loadScript(loadPath + 'mindmap/d3@5',function(){
editormd.loadScript(loadPath + 'mindmap/transform.min', function(){
editormd.loadScript(loadPath + 'mindmap/view.min',function(){
})
})
})
editormd.loadCSS(loadPath + "codemirror/lib/codemirror");
if (settings.searchReplace && !settings.readOnly)
@ -4457,7 +4465,13 @@
if (settings.previewCodeHighlight)
{
div.find("pre").addClass("prettyprint linenums");
prettyPrint();
editormd.loadScript('/static/editor.md/lib/raphael.min', function(){
editormd.loadScript('/static/editor.md/lib/underscore.min', function(){
editormd.loadScript('/static/editor.md/lib/prettify.min',function(){
prettyPrint();
})
})
})
}
if (!editormd.isIE8)
@ -4485,8 +4499,10 @@
has_sequence_dia = true;
})
if(has_sequence_dia){
editormd.loadScript('/static/editor.md/lib/sequence-diagram.min',function(){
div.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
editormd.loadScript('/static/editor.md/lib/underscore.min', function(){
editormd.loadScript('/static/editor.md/lib/sequence-diagram.min',function(){
div.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
})
})
}
// div.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
@ -4529,9 +4545,9 @@
console.log("存在脑图")
var mmap = $(this);
var mmap_id = this.id;
editormd.loadScript('/static/mindmap/d3@5',function(){
editormd.loadScript('/static/mindmap/transform.min',function(){
editormd.loadScript('/static/mindmap/view.min',function(){
editormd.loadScript('/static/editor.md/lib/mindmap/d3@5',function(){
editormd.loadScript('/static/editor.md/lib/mindmap/transform.min',function(){
editormd.loadScript('/static/editor.md/lib/mindmap/view.min',function(){
var md_data = window.markmap.transform(mmap.text().trim());
window.markmap.markmap("svg#"+mmap_id,md_data)
})
@ -4713,9 +4729,7 @@
// 使用国外的CDN加载速度有时会很慢或者自定义URL
// You can custom KaTeX load url.
editormd.katexURL = {
//css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min",
css : "/static/katex/katex.min",
//js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min"
js : "/static/katex/katex.min",
};

Binary file not shown.

2
static/editor.md/lib/mindmap/d3@5.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -320,9 +320,6 @@
<script src="{% static 'vditor/dist/method.min.js' %}?version={{mrdoc_version}}"></script>
{% elif doc.editor_mode == 1 %}
<script src="{% static 'editor.md/lib/marked.min.js' %}"></script>
<script src="{% static 'editor.md/lib/prettify.min.js' %}"></script>
<script src="{% static 'editor.md/lib/raphael.min.js' %}"></script>
<script src="{% static 'editor.md/lib/underscore.min.js' %}"></script>
<script src="{% static 'editor.md/editormd.js' %}?version={{mrdoc_version}}"></script>
{% endif %}

View File

@ -226,9 +226,6 @@
<!-- 加载编辑器 -->
{% if editor_mode == 1 %}
<!-- Editor.MD编辑器 -->
<script src="{% static 'mindmap/d3@5.js' %}"></script>
<script src="{% static 'mindmap/transform.min.js' %}"></script>
<script src="{% static 'mindmap/view.min.js' %}"></script>
<script src="{% static 'editor.md/editormd.js' %}?version={{mrdoc_version}}"></script>
{% include 'app_doc/editor/tpl_editor_editormd.html' %}
{% elif editor_mode == 2 %}

View File

@ -146,14 +146,8 @@
{% endblock %}
{% block custom_script %}
<link rel="stylesheet" href="{% static 'vditor/dist/index.css' %}?version={{mrdoc_version}}" />
<style>
.vditor-reset{
font-size: inherit;
font-family:inherit;
}
</style>
<script src="{% static 'vditor/dist/method.min.js' %}"></script>
<script src="{% static 'editor.md/lib/marked.min.js' %}"></script>
<script src="{% static 'editor.md/editormd.js' %}?version={{mrdoc_version}}"></script>
<script>
// 生成文集简介中的文档大纲
$.ajaxSetup({
@ -205,18 +199,19 @@
getDocTree();
// 渲染文集简介Markdown
const renderDesc = () => {
const md_desc = $("#project-desc textarea").val()
Vditor.preview(document.getElementById('project-desc'),
md_desc, {
"cdn":"{% static 'vditor' %}",
speech: {
enable: true,
},
anchor: 1,
after:function(){
layer.closeAll('loading');
}
})
editormd.markdownToHTML("project-desc", {
emoji : true, //emoji表情
taskList : true, // 任务列表
tex : true, // 科学公式
flowChart : true, // 流程图
sequenceDiagram : true, // 时序图
tocm : false, //目录
toc :false,
tocContainer : "#toc-container",
tocDropdown : false,
atLink : false,//禁用@链接
htmlDecode : "link,style,base,script,iframe", //过滤部分HTML标签
});
}
layer.load(1);
renderDesc();