当前位置:   article > 正文

Markdown编辑器Editor.md插件的使用_editormd插件

editormd插件

官网: 

Editor.md - 开源在线 Markdown 编辑器 (pandao.github.io)icon-default.png?t=M5H6https://pandao.github.io/editor.md/index.html配置项:

  1. var testEditor;
  2. testEditor = editormd("test-editormd", {
  3. placeholder:'本编辑器支持Markdown编辑,左边编写,右边预览', //默认显示的文字,这里就不解释了
  4. width: "90%",
  5. height: 640,
  6. syncScrolling: "single",
  7. path: "lib/js/editor.md-master/lib/", //你的path路径(原资源文件中lib包在我们项目中所放的位置)
  8. theme: "dark",//工具栏主题
  9. previewTheme: "dark",//预览主题
  10. editorTheme: "pastel-on-dark",//编辑主题
  11. saveHTMLToTextarea: true,
  12. emoji: false,
  13. taskList: true,
  14. tocm: true, // Using [TOCM]
  15. tex: true, // 开启科学公式TeX语言支持,默认关闭
  16. flowChart: true, // 开启流程图支持,默认关闭
  17. sequenceDiagram: true, // 开启时序/序列图支持,默认关闭,
  18. toolbarIcons : function() { //自定义工具栏,后面有详细介绍
  19. return editormd.toolbarModes['simple']; // full, simple, mini
  20. },
  21. });
  22. //上面的挑有用的写上去就行

获取Markdown格式的文本

document.querySelector('.editormd-markdown-textarea').value 

获取markdown渲染过的文章

document.querySelector('.markdown-body').textContent,

 自定义工具栏

工具栏分为三组,full, simple, mini这三个,可以选择,也可以自由的设置工具栏,自由的设置工具栏在官网中有写,在这里就只介绍3组。

  1. t.toolbarModes={
  2. 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"],
  3. 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"],
  4. mini:["undo","redo","|","watch","preview","|","help","info"]
  5. }

每一个标签表示一个工具,也可以随意使用上面的标签自定义工具栏,每个标签具体表示的工具官网上没有,所以只能与工具栏对照一下才行了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/548135
推荐阅读
相关标签
  

闽ICP备14008679号