editor.md 配置参数和使用方法

[复制链接]
查看: 295|回复: 0

9

主题

9

帖子

31

积分

新手上路

Rank: 1

积分
31
发表于 2020-12-29 15:32:51 | 显示全部楼层 |阅读模式
  1. <script>
  2.             var testEditor;
  3.             $(function() {
  4.                 $.get('test.md', function(md){
  5.                     testEditor = editormd("test-editormd", {
  6.                         width: "90%",
  7.                         height: 740,
  8.                         path : '../lib/',
  9.                         theme : "dark",
  10.                         previewTheme : "dark",
  11.                         editorTheme : "pastel-on-dark",
  12.                         markdown : md,
  13.                         codeFold : true,
  14.                         //syncScrolling : false,
  15.                         saveHTMLToTextarea : true,    // 保存 HTML 到 Textarea
  16.                         searchReplace : true,
  17.                         //watch : false,                // 关闭实时预览
  18.                         htmlDecode : "style,script,iframe|on*",            // 开启 HTML 标签解析,为了安全性,默认不开启   
  19.                         //toolbar  : false,             //关闭工具栏
  20.                         //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮,默认开启
  21.                         emoji : true,
  22.                         taskList : true,
  23.                         tocm            : true,         // Using [TOCM]
  24.                         tex : true,                   // 开启科学公式TeX语言支持,默认关闭
  25.                         flowChart : true,             // 开启流程图支持,默认关闭
  26.                         sequenceDiagram : true,       // 开启时序/序列图支持,默认关闭,
  27.                         //dialogLockScreen : false,   // 设置弹出层对话框不锁屏,全局通用,默认为true
  28.                         //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
  29.                         //dialogDraggable : false,    // 设置弹出层对话框不可拖动,全局通用,默认为true
  30.                         //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度,全局通用,默认值为0.1
  31.                         //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
  32.                         imageUpload : true,
  33.                         imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
  34.                         imageUploadURL : "./php/upload.php",
  35.                         onload : function() {
  36.                             console.log('onload', this);
  37.                             //this.fullscreen();
  38.                             //this.unwatch();
  39.                             //this.watch().fullscreen();
  40.                             //this.setMarkdown("#PHP");
  41.                             //this.width("100%");
  42.                             //this.height(480);
  43.                             //this.resize("100%", 640);
  44.                         }
  45.                     });
  46.                 });
  47.            
  48.                 testEditor.gotoLine(90);//转到第90行

  49.                 testEditor.show();//显示编辑器

  50.                 testEditor.hide();//隐藏编辑器

  51.                 alert(testEditor.getMarkdown());//获取编辑器内容(不含html)

  52.                alert(testEditor.getHTML());//获取编辑器html内容
  53.            
  54.                testEditor.watch();//开启双窗口对比
  55.                           
  56.                testEditor.unwatch();//取消双窗口对比
  57.                      
  58.                testEditor.previewing();//预览效果
  59.               
  60.                testEditor.fullscreen();//全屏(按ESC取消)
  61.               
  62.                testEditor.showToolbar();//显示工具栏

  63.                testEditor.hideToolbar();//隐藏工具栏
  64.            
  65.                testEditor.config({
  66.                         tocDropdown   : true,
  67.                         tocTitle      : "目录 Table of Contents",
  68.                });//TOC下拉菜单
  69.                
  70.               testEditor.config("tocDropdown", false);//TOC默认                           });
  71. </script>
复制代码
editor.md 配置参数和使用方法
腾讯云
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精彩图文



在线客服(工作时间:9:00-22:00)
400-600-6565

内容导航

微信客服

Copyright   ©2015-2019  云服务器社区  Powered by©Discuz!  技术支持:尊托网络     ( 湘ICP备15009499号-1 )