优化editormd编辑器预览界面代码高亮效果

This commit is contained in:
yangjian 2023-05-09 10:16:30 +08:00
parent 2dd98ad186
commit 6fa1019175
2 changed files with 10 additions and 18 deletions

View File

@ -611,17 +611,8 @@
editormd.loadScript(loadPath + "marked.min", function() {
editormd.$marked = marked;
if (settings.previewCodeHighlight)
{
editormd.loadScript(loadPath + "prettify.min", function() {
loadFlowChartOrSequenceDiagram();
});
}
else
{
loadFlowChartOrSequenceDiagram();
}
loadFlowChartOrSequenceDiagram();
});
});
@ -1539,12 +1530,12 @@
if (settings.previewCodeHighlight)
{
previewContainer.find("pre").addClass("prettyprint linenums");
if (typeof prettyPrint !== "undefined")
{
prettyPrint();
}
previewContainer.find("pre").addClass("line-numbers language-bash");
previewContainer.find("pre").attr('data-prismjs-copy','复制');
previewContainer.find("pre").attr('data-prismjs-copy-error','按Ctrl+C复制');
previewContainer.find("pre").attr('data-prismjs-copy-success','代码已复制!');
let preCodes = Array.from(previewContainer.find("pre code"))
preCodes.forEach(block => Prism.highlightElement(block));
}
return this;
@ -4425,7 +4416,6 @@
if (settings.previewCodeHighlight)
{
// div.find("pre").addClass("prettyprint linenums");
editormd.loadScript(settings.plugin_path + 'raphael.min', function(){
editormd.loadScript(settings.plugin_path + 'underscore.min', function(){
// editormd.loadScript(settings.plugin_path + 'prettify.min',function(){

View File

@ -31,6 +31,7 @@
<link href="{% static 'mrdoc/mrdoc.css' %}?version={{mrdoc_version}}" rel="stylesheet">
<link href="{% static 'mrdoc/mrdoc-editor.css' %}?version={{mrdoc_version}}" rel="stylesheet">
<link href="{% static 'tagsInput/tagsinput.css' %}" rel="stylesheet" type="text/css"/>
<link href="{% static 'prismjs/prism.css' %}?version={{mrdoc_version}}" rel="stylesheet">
<style>
</style>
@ -259,6 +260,7 @@
</script>
<script src="{% static 'mrdoc/mrdoc.editor.js' %}?version={{mrdoc_version}}"></script>
<script src="{% static 'mrdoc/mrdoc.js' %}?version={{mrdoc_version}}"></script>
<script src="{% static 'prismjs/prism.js' %}?version={{mrdoc_version}}"></script>
{% block custom_script %}
{% endblock %}
</body>