full.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Full example - 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. <style>
  10. /*.editormd-preview-theme-dark {
  11. color: #777;
  12. background:#2C2827;
  13. }
  14. .editormd-preview-theme-dark .editormd-toc-menu > .markdown-toc {
  15. background:#fff;
  16. border:none;
  17. }
  18. .editormd-preview-theme-dark .editormd-toc-menu > .markdown-toc h1{
  19. border-color:#ddd;
  20. }
  21. .editormd-preview-theme-dark .markdown-body h1,
  22. .editormd-preview-theme-dark .markdown-body h2,
  23. .editormd-preview-theme-dark .markdown-body hr {
  24. border-color: #222;
  25. }
  26. .editormd-preview-theme-dark .editormd-preview-container blockquote {
  27. color: #555;
  28. border-color: #333;
  29. background: #222;
  30. padding: 0.5em;
  31. }
  32. .editormd-preview-theme-dark .editormd-preview-container abbr {
  33. background:#ff9900;
  34. color: #fff;
  35. padding: 1px 3px;
  36. border-radius: 3px;
  37. }
  38. .editormd-preview-theme-dark .editormd-preview-container code {
  39. background: #5A9600;
  40. color: #fff;
  41. border: none;
  42. padding: 1px 3px;
  43. border-radius: 3px;
  44. }
  45. .editormd-preview-theme-dark .editormd-preview-container table {
  46. border: none;
  47. }
  48. .editormd-preview-theme-dark .editormd-preview-container .fa-emoji {
  49. color: #B4BF42;
  50. }
  51. .editormd-preview-theme-dark .editormd-preview-container .katex {
  52. color: #FEC93F;
  53. }
  54. .editormd-preview-theme-dark [class*=editormd-logo] {
  55. color: #2196F3;
  56. }
  57. .editormd-preview-theme-dark .sequence-diagram text {
  58. fill: #fff;
  59. }
  60. .editormd-preview-theme-dark .sequence-diagram rect,
  61. .editormd-preview-theme-dark .sequence-diagram path {
  62. color:#fff;
  63. fill : #64D1CB;
  64. stroke : #64D1CB;
  65. }
  66. .editormd-preview-theme-dark .flowchart rect,
  67. .editormd-preview-theme-dark .flowchart path {
  68. stroke : #A6C6FF;
  69. }
  70. .editormd-preview-theme-dark .flowchart rect {
  71. fill: #A6C6FF;
  72. }
  73. .editormd-preview-theme-dark .flowchart text {
  74. fill: #5879B4;
  75. }*/
  76. </style>
  77. </head>
  78. <body>
  79. <div id="layout">
  80. <header>
  81. <h1>完整示例</h1>
  82. <p>Full example</p>
  83. <ul style="margin: 10px 0 0 18px;">
  84. <li>Enable HTML tags decode</li>
  85. <li>Enable TeX, Flowchart, Sequence Diagram, Emoji, FontAwesome, Task lists</li>
  86. <li>Enable Image upload</li>
  87. <li>Enable [TOCM], Search Replace, Code fold</li>
  88. </ul>
  89. </header>
  90. <div class="btns">
  91. <button id="goto-line-btn">Goto line 90</button>
  92. <button id="show-btn">Show editor</button>
  93. <button id="hide-btn">Hide editor</button>
  94. <button id="get-md-btn">Get Markdown</button>
  95. <button id="get-html-btn">Get HTML</button>
  96. <button id="watch-btn">Watch</button>
  97. <button id="unwatch-btn">Unwatch</button>
  98. <button id="preview-btn">Preview HTML (Press Shift + ESC cancel)</button>
  99. <button id="fullscreen-btn">Fullscreen (Press ESC cancel)</button>
  100. <button id="show-toolbar-btn">Show toolbar</button>
  101. <button id="close-toolbar-btn">Hide toolbar</button>
  102. <button id="toc-menu-btn">ToC Dropdown menu</button>
  103. <button id="toc-default-btn">ToC default</button>
  104. </div>
  105. <div id="test-editormd"></div>
  106. </div>
  107. <script src="js/jquery.min.js"></script>
  108. <script src="../editormd.js"></script>
  109. <script type="text/javascript">
  110. var testEditor;
  111. $(function() {
  112. $.get('test.md', function(md){
  113. testEditor = editormd("test-editormd", {
  114. width: "90%",
  115. height: 740,
  116. path : '../lib/',
  117. theme : "dark",
  118. previewTheme : "dark",
  119. editorTheme : "pastel-on-dark",
  120. markdown : md,
  121. codeFold : true,
  122. //syncScrolling : false,
  123. saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
  124. searchReplace : true,
  125. //watch : false, // 关闭实时预览
  126. htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
  127. //toolbar : false, //关闭工具栏
  128. //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮,默认开启
  129. emoji : true,
  130. taskList : true,
  131. tocm : true, // Using [TOCM]
  132. tex : true, // 开启科学公式TeX语言支持,默认关闭
  133. flowChart : true, // 开启流程图支持,默认关闭
  134. sequenceDiagram : true, // 开启时序/序列图支持,默认关闭,
  135. //dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为true
  136. //dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
  137. //dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为true
  138. //dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为0.1
  139. //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
  140. imageUpload : true,
  141. imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
  142. imageUploadURL : "./php/upload.php",
  143. onload : function() {
  144. console.log('onload', this);
  145. //this.fullscreen();
  146. //this.unwatch();
  147. //this.watch().fullscreen();
  148. //this.setMarkdown("#PHP");
  149. //this.width("100%");
  150. //this.height(480);
  151. //this.resize("100%", 640);
  152. }
  153. });
  154. });
  155. $("#goto-line-btn").bind("click", function(){
  156. testEditor.gotoLine(90);
  157. });
  158. $("#show-btn").bind('click', function(){
  159. testEditor.show();
  160. });
  161. $("#hide-btn").bind('click', function(){
  162. testEditor.hide();
  163. });
  164. $("#get-md-btn").bind('click', function(){
  165. alert(testEditor.getMarkdown());
  166. });
  167. $("#get-html-btn").bind('click', function() {
  168. alert(testEditor.getHTML());
  169. });
  170. $("#watch-btn").bind('click', function() {
  171. testEditor.watch();
  172. });
  173. $("#unwatch-btn").bind('click', function() {
  174. testEditor.unwatch();
  175. });
  176. $("#preview-btn").bind('click', function() {
  177. testEditor.previewing();
  178. });
  179. $("#fullscreen-btn").bind('click', function() {
  180. testEditor.fullscreen();
  181. });
  182. $("#show-toolbar-btn").bind('click', function() {
  183. testEditor.showToolbar();
  184. });
  185. $("#close-toolbar-btn").bind('click', function() {
  186. testEditor.hideToolbar();
  187. });
  188. $("#toc-menu-btn").click(function(){
  189. testEditor.config({
  190. tocDropdown : true,
  191. tocTitle : "目录 Table of Contents",
  192. });
  193. });
  194. $("#toc-default-btn").click(function() {
  195. testEditor.config("tocDropdown", false);
  196. });
  197. });
  198. </script>
  199. </body>
  200. </html>