Open cnspray opened 4 years ago
解决问题的方法,用 PR 通知作者会比较好。
https://github.com/pandao/editor.md/issues/790 是否考虑加入导入word文档和支持从office文档粘贴转换为markdown的功能?
https://github.com/mindoc-org/mindoc/issues/603 按照这个方式可以。另外,本身它就支持mermaid各种思维导图
graph TD
B["fa:fa-twitter for peace"]
B-->C[fa:fa-ban forbidden]
B-->D(fa:fa-spinner);
一、增加按钮
增加一个div,用于按钮帮助
else if (name=="mindmap"){//流程图说明 var cm = window.editor.cm; var selection = cm.getSelection(); var cursor = cm.getCursor(); if (selection === "") { cm.replaceSelection("\n"+$("#mindmaphelp").text() + selection+"\n\n"); cm.setCursor(cursor.line+11, 0); cm. focus() ; }else { var selectionText = selection.split("\n"); for (var i = 0, len = selectionText.length; i < len; i++) { selectionText[i] = (selectionText[i] === "") ? "" : $("#mindmaphelp").text() + selectionText[i]; } cm.replaceSelection(selectionText.join("\n\n")); cm.setCursor(cursor.line+11, 0); cm. focus() ; } }
// 将 li 节点转换为 JSON 数据 function li2jsonData(liNode) { var liData; var aNode = liNode.children("a:first"); if (aNode.length !== 0) { liData = { "data": { "text": aNode.text(), "hyperlink": aNode.attr("href") } }; } else { liData = { "data": { "text": liNode[0].childNodes[0].nodeValue.trim() } }; }
}
function drawMindMap(div) { //各参数解析开始 var lang = $(div).find(".mindmapoption").text(); var sizeps = lang.match(/(?<=size:)(mindmap-sm|mindmap-md|mindmap-lg)(?= )/i); var Templateps = lang.match(/(?<=Template:)(fresh-blue|filetree|fish-bone|right|structure|tianpan)(?= )/i); var Themeps = lang.match(/(?<=Theme:)(classic|classic-compact|fish|fresh-blue|fresh-blue-compat|fresh-green|fresh-green-compat|fresh-pink|fresh-pink-compat|fresh-purple|fresh-purple-compat|fresh-red|fresh-red-compat|fresh-soil|fresh-soil-compat|snow|snow-compact|tianpan|tianpan-compact|wire)(?= )/i); var protocolps = lang.match(/(?<=protocol:)(json|text|markdown|list)(?= )/i); var tmpshowps = lang.match(/(?<=tmpshow:)(true)(?= )/i); var size = (sizeps !== null) ? sizeps[0] : "mindmap-md"; var Theme = (Themeps !== null) ? Themeps[0] : "default"; var protocol = (protocolps !== null) ? protocolps[0] : "markdown"; var Template = (Templateps !== null) ? Templateps[0] : "default"; var tmpshow = (tmpshowps !== null) ? "": "style=\"display:none;\""; //参数解析结束 var markdownText = $(div).find(".mindmaptmp").text().trim(); if (protocol == "list") { var ulElement = $(div).find(".mindmaptmp").find(">ul:first"); var mmData = { "root": {} }; var minder = new kityminder.Minder({ renderTo: div }); try { mmData.root = li2jsonData(ulElement.children("li:first")); mmData.template = Template; mmData.theme = Theme; minder.importData('json', JSON.stringify(mmData)); minder.disable(); / minder.setTemplate(Template); minder.setTheme(Theme); / minder.execCommand('hand'); } catch(e) { console.log(e); }
}
.km-view { font-family: "STHeitiSC-Light", "STHeiti", "Hei", "Heiti SC", "Microsoft Yahei", Arial, sans-serif; -webkit-user-select: none; user-select: none; position: relative; }
.km-view .km-receiver { position: absolute; left: -99999px; top: -99999px; width: 20px; height: 20px; outline: none; margin: 0; }
.km-view image { cursor: zoom-in; }
.km-image-viewer { position: fixed; z-index: 99999; top: 0; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, .75); }
.km-image-viewer .km-image-viewer-container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; text-align: center; white-space: nowrap; overflow: auto; }
.km-image-viewer .km-image-viewer-container::before { content: ''; display: inline-block; height: 100%; width: 0; font-size: 0; vertical-align: middle; }
.km-image-viewer .km-image-viewer-container img { cursor: zoom-out; vertical-align: middle; }
.km-image-viewer .km-image-viewer-container img.limited { cursor: zoom-in; max-width: 100%; max-height: 100%; }
.km-image-viewer .km-image-viewer-toolbar { z-index: 1; background: rgba(0, 0, 0, .75); text-align: right; transition: all .25s; }
.km-image-viewer .km-image-viewer-toolbar.hidden { transform: translate(0, -100%); opacity: 0; }
.km-image-viewer .km-image-viewer-btn { cursor: pointer; outline: 0; border: 0; width: 44px; height: 44px; background: url("data:image/svg+xml;base64,PHN2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: absolute; top: 0; left: 0; right: 0; }
.km-image-viewer .km-image-viewer-close { background-position: 0 -44px; }
.mindmap { width: inherit; border: 1px solid #ccc; }
.mindmap-sm { height: 300px; }
.mindmap-md { height: 500px; }
.mindmap-lg { height: 800px; }