resettings.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Resettings - Editor.md examples</title>
  6. <link rel="stylesheet" href="css/style.css" />
  7. <link rel="stylesheet" href="../css/editormd.css" />
  8. <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
  9. </head>
  10. <body>
  11. <div id="layout">
  12. <header>
  13. <h1>Resettings</h1>
  14. <p>只能设置依赖模块加载完成之后的相关配置或者使用拖动加载模块方式。</p>
  15. <p>Only be resetting the relevant configuration of dependent module loaded after, or using manually load modules mode.</p>
  16. </header>
  17. <div class="btns">
  18. <button id="show-btn">Show editor</button>
  19. <button id="hide-btn">Hide editor</button>
  20. <button id="get-md-btn">Get Markdown</button>
  21. <button id="get-html-btn">Get HTML</button>
  22. <button id="watch-btn">Watch</button>
  23. <button id="unwatch-btn">Unwatch</button>
  24. <button id="preview-btn">Preview HTML(Press ESC cancel)</button>
  25. <button id="fullscreen-btn">Fullscreen (Press ESC cancel)</button>
  26. <button id="show-toolbar-btn">Show toolbar</button>
  27. <button id="close-toolbar-btn">Hide toolbar</button>
  28. </div>
  29. <div id="test-editormd">
  30. <textarea style="display:none;">#### Resetting examples
  31. ```javascript
  32. this.config("lineNumbers", false);
  33. this.config({
  34. toc : false,
  35. tex : false,
  36. previewCodeHighlight : true, // before set previewCodeHighlight == false, editor not load pretty.js, so now codes can't highlight and display line numbers.
  37. flowChart : false,
  38. sequenceDiagram : false,
  39. dialogLockScreen : false,
  40. dialogDraggable : false,
  41. dialogMaskBgColor : "teal",
  42. toolbar : true
  43. });
  44. this.config("onresize", function() {
  45. console.log("onresize =&gt;", this);
  46. });
  47. ```</textarea></div>
  48. </div>
  49. <script src="js/jquery.min.js"></script>
  50. <script src="../editormd.js"></script>
  51. <script type="text/javascript">
  52. var testEditor;
  53. $(function() {
  54. $.get("test.md", function(md) {
  55. testEditor = editormd("test-editormd", {
  56. width : "90%",
  57. height : 740,
  58. path : "../lib/",
  59. appendMarkdown : "\n" + md,
  60. saveHTMLToTextarea : true,
  61. watch : false,
  62. htmlDecode : true,
  63. toolbar : false,
  64. previewCodeHighlight : false,
  65. tex : true,
  66. flowChart : true,
  67. sequenceDiagram : true,
  68. emoji : true,
  69. taskList : true,
  70. onload : function() {
  71. console.log('onload', this);
  72. this.config("lineNumbers", false);
  73. this.config({
  74. toc : false,
  75. tex : false,
  76. toolbar : true,
  77. previewCodeHighlight : true, // before set previewCodeHighlight == false, editor not load pretty.js, so now codes can't highlight and display line numbers.
  78. flowChart : false,
  79. sequenceDiagram : false,
  80. dialogLockScreen : false,
  81. dialogMaskOpacity : 0.5, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
  82. dialogDraggable : false,
  83. dialogMaskBgColor : "#000"
  84. });
  85. this.config("onresize", function() {
  86. console.log("onresize =>", this);
  87. });
  88. this.watch();
  89. }
  90. });
  91. });
  92. $("#show-btn").click(function(){
  93. testEditor.show();
  94. });
  95. $("#hide-btn").click(function(){
  96. testEditor.hide();
  97. });
  98. $("#get-md-btn").click(function(){
  99. alert(testEditor.getMarkdown());
  100. });
  101. $("#get-html-btn").click(function() {
  102. alert(testEditor.getHTML());
  103. });
  104. $("#watch-btn").click(function() {
  105. testEditor.watch();
  106. });
  107. $("#unwatch-btn").click(function() {
  108. testEditor.unwatch();
  109. });
  110. $("#preview-btn").click(function() {
  111. testEditor.previewing();
  112. });
  113. $("#fullscreen-btn").click(function() {
  114. testEditor.fullscreen();
  115. });
  116. $("#show-toolbar-btn").click(function() {
  117. testEditor.showToolbar();
  118. });
  119. $("#close-toolbar-btn").click(function() {
  120. testEditor.hideToolbar();
  121. });
  122. });
  123. </script>
  124. </body>
  125. </html>