赞
踩
官网:
Editor.md - 开源在线 Markdown 编辑器 (pandao.github.io)https://pandao.github.io/editor.md/index.html配置项:
- var testEditor;
- testEditor = editormd("test-editormd", {
- placeholder:'本编辑器支持Markdown编辑,左边编写,右边预览', //默认显示的文字,这里就不解释了
- width: "90%",
- height: 640,
- syncScrolling: "single",
- path: "lib/js/editor.md-master/lib/", //你的path路径(原资源文件中lib包在我们项目中所放的位置)
- theme: "dark",//工具栏主题
- previewTheme: "dark",//预览主题
- editorTheme: "pastel-on-dark",//编辑主题
- saveHTMLToTextarea: true,
- emoji: false,
- taskList: true,
- tocm: true, // Using [TOCM]
- tex: true, // 开启科学公式TeX语言支持,默认关闭
- flowChart: true, // 开启流程图支持,默认关闭
- sequenceDiagram: true, // 开启时序/序列图支持,默认关闭,
- toolbarIcons : function() { //自定义工具栏,后面有详细介绍
- return editormd.toolbarModes['simple']; // full, simple, mini
- },
- });
- //上面的挑有用的写上去就行
获取Markdown格式的文本
document.querySelector('.editormd-markdown-textarea').value
获取markdown渲染过的文章
document.querySelector('.markdown-body').textContent,
自定义工具栏
工具栏分为三组,full, simple, mini这三个,可以选择,也可以自由的设置工具栏,自由的设置工具栏在官网中有写,在这里就只介绍3组。
- t.toolbarModes={
- full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],
- simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],
- mini:["undo","redo","|","watch","preview","|","help","info"]
- }
每一个标签表示一个工具,也可以随意使用上面的标签自定义工具栏,每个标签具体表示的工具官网上没有,所以只能与工具栏对照一下才行了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。