Merge pull request #731 from jh244212647/master

feature-mindmap: editor.md add mindmap
pull/733/head
玖亖伍 2021-09-28 13:50:33 +08:00 committed by GitHub
commit e0f6af036b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8758 additions and 1 deletions

64
static/editor.md/editormd.js 100644 → 100755
View File

@ -170,6 +170,7 @@
flowChart : false, // flowChart.js only support IE9+ flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+ sequenceDiagram : false, // sequenceDiagram.js only support IE9+
mermaid : true, mermaid : true,
mindMap : true, // 脑图
previewCodeHighlight : true, previewCodeHighlight : true,
toolbar : true, // show/hide toolbar toolbar : true, // show/hide toolbar
@ -569,6 +570,20 @@
}); });
} }
if (settings.mindMap)
{
editormd.loadScript(loadPath + "mindmap/transform.min", function() {
editormd.loadScript(loadPath + "mindmap/d3@5", function() {
editormd.loadScript(loadPath + "mindmap/view.min", function() {
if (!isLoadedDisplay){
isLoadedDisplay = true;
_this.loadedDisplay();
}
});
});
});
}
if(settings.sequenceDiagram) { if(settings.sequenceDiagram) {
editormd.loadCSS(loadPath + "sequence/sequence-diagram-min", function () { editormd.loadCSS(loadPath + "sequence/sequence-diagram-min", function () {
editormd.loadScript(loadPath + "sequence/webfont", function() { editormd.loadScript(loadPath + "sequence/webfont", function() {
@ -1560,6 +1575,22 @@
return this; return this;
}, },
/**
* - 2020-04-12
*
* @returns {editormd} editormd
*/
mindmapRender:function(){
this.previewContainer.find(".mindmap").each(function(){
var mmap = $(this);
var md_data = window.markmap.transform(mmap.text().trim());
window.markmap.markmap("svg#"+this.id,md_data)
});
return this;
},
/** /**
* *
* FlowChart and SequenceDiagram Renderer * FlowChart and SequenceDiagram Renderer
@ -2069,6 +2100,7 @@
sequenceDiagram : settings.sequenceDiagram, sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight, previewCodeHighlight : settings.previewCodeHighlight,
mermaid : settings.mermaid, mermaid : settings.mermaid,
mindMap : settings.mindMap, // 思维导图
}; };
var markedOptions = this.markedOptions = { var markedOptions = this.markedOptions = {
@ -2150,6 +2182,14 @@
} }
} }
// 渲染脑图
if(settings.mindMap){
setTimeout(function(){
_this.mindmapRender();
},10)
}
if (settings.flowChart || settings.sequenceDiagram || settings.mermaid) if (settings.flowChart || settings.sequenceDiagram || settings.mermaid)
{ {
flowchartTimer = setTimeout(function(){ flowchartTimer = setTimeout(function(){
@ -3896,6 +3936,16 @@
{ {
return "<p class=\"" + editormd.classNames.tex + "\">" + code + "</p>"; return "<p class=\"" + editormd.classNames.tex + "\">" + code + "</p>";
} }
else if (/^mindmap/i.test(lang)){
  var len = 9 || 32;
  var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  var maxPos = $chars.length;
  var map_id = '';
  for (var i = 0; i < len; i++) {
    map_id += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return "<svg class='mindmap' style='width:100%;min-height=150px;' id='mindmap-"+ map_id +"'>"+code+"</svg>";
}
else else
{ {
@ -4183,6 +4233,7 @@
sequenceDiagram : false, sequenceDiagram : false,
previewCodeHighlight : true, previewCodeHighlight : true,
mermaid : true, mermaid : true,
mindMap : true, //思维导图
}; };
editormd.$marked = marked; editormd.$marked = marked;
@ -4213,6 +4264,7 @@
flowChart : settings.flowChart, flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram, sequenceDiagram : settings.sequenceDiagram,
mermaid : settings.mermaid, mermaid : settings.mermaid,
mindMap : settings.mindMap, // 思维导图
previewCodeHighlight : settings.previewCodeHighlight, previewCodeHighlight : settings.previewCodeHighlight,
}; };
@ -4307,6 +4359,18 @@
} }
} }
// 前台渲染脑图
if(settings.mindMap){
var mindmapHandle = function(){
div.find(".mindmap").each(function(){
var mmap = $(this);
var md_data = window.markmap.transform(mmap.text().trim());
window.markmap.markmap("svg#"+this.id,md_data)
});
}
mindmapHandle();
}
div.getMarkdown = function() { div.getMarkdown = function() {
return saveTo.val(); return saveTo.val();
}; };

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