use-zepto.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Using Zepto.js - 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>Using Zepto.js</h1>
  14. <ul style="margin: 10px 0 0 18px;">
  15. <li>Enable HTML tags decode</li>
  16. <li>Enable TeX, Flowchart, Sequence Diagram, Emoji, FontAwesome, Task lists</li>
  17. <li>Enable Image upload</li>
  18. <li>Enable [TOCM], Search Replace, Code fold</li>
  19. </ul>
  20. </header>
  21. <div class="btns">
  22. <button id="show-btn">Show editor</button>
  23. <button id="hide-btn">Hide editor</button>
  24. <button id="get-md-btn">Get Markdown</button>
  25. <button id="get-html-btn">Get HTML</button>
  26. <button id="watch-btn">Watch</button>
  27. <button id="unwatch-btn">Unwatch</button>
  28. <button id="preview-btn">Preview HTML (Press Shift + ESC cancel)</button>
  29. <button id="fullscreen-btn">Fullscreen (Press ESC cancel)</button>
  30. <button id="show-toolbar-btn">Show toolbar</button>
  31. <button id="close-toolbar-btn">Hide toolbar</button>
  32. <button id="toc-menu-btn">ToC Dropdown menu</button>
  33. <button id="toc-default-btn">ToC default</button>
  34. </div>
  35. <form action="http://editormd.ipandao.com/php/post.php" method="post">
  36. <div class="editormd" id="test-editormd">
  37. <textarea>### Hello world!</textarea>
  38. </div>
  39. <br/><input type="submit" name="submit" value="Submit" class="btn" style="margin-left: 5%;" />
  40. </form>
  41. </div>
  42. <script src="js/zepto.min.js"></script>
  43. <script src="../editormd.js"></script>
  44. <script type="text/javascript">
  45. var testEditor;
  46. var jQuery = Zepto; // 为了避免修改 flowChart.js 和 sequence-diagram.js 的源码,所以想支持 flowChart / sequenceDiagram 就得加上这一句
  47. $(function() {
  48. $.get("./test.md", function(md){
  49. testEditor = editormd("test-editormd", {
  50. width : "90%",
  51. height : 720,
  52. path : '../lib/',
  53. markdown : md,
  54. codeFold : true,
  55. searchReplace : true,
  56. saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
  57. //watch : false,
  58. htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
  59. emoji : true,
  60. taskList : true,
  61. tocm : true, // Using [TOCM]
  62. tex : true, // 开启科学公式 TeX 语言支持,默认关闭
  63. //previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
  64. flowChart : true,
  65. sequenceDiagram : true, // 同上
  66. onload : function() {
  67. console.log("onload =>", this, this.id, this.settings);
  68. }
  69. });
  70. });
  71. $("#show-btn").bind('click', function(){
  72. testEditor.show();
  73. });
  74. $("#hide-btn").bind('click', function(){
  75. testEditor.hide();
  76. });
  77. $("#get-md-btn").bind('click', function(){
  78. alert(testEditor.getMarkdown());
  79. });
  80. $("#get-html-btn").bind('click', function() {
  81. alert(testEditor.getHTML());
  82. });
  83. $("#watch-btn").bind('click', function() {
  84. testEditor.watch();
  85. });
  86. $("#unwatch-btn").bind('click', function() {
  87. testEditor.unwatch();
  88. });
  89. $("#preview-btn").bind('click', function() {
  90. testEditor.previewing();
  91. });
  92. $("#fullscreen-btn").bind('click', function() {
  93. testEditor.fullscreen();
  94. });
  95. $("#show-toolbar-btn").bind('click', function() {
  96. testEditor.showToolbar();
  97. });
  98. $("#close-toolbar-btn").bind('click', function() {
  99. testEditor.hideToolbar();
  100. });
  101. $("#toc-menu-btn").click(function(){
  102. testEditor.config({
  103. tocDropdown : true,
  104. tocTitle : "目录 Table of Contents",
  105. });
  106. });
  107. $("#toc-default-btn").click(function() {
  108. testEditor.config("tocDropdown", false);
  109. });
  110. });
  111. </script>
  112. </body>
  113. </html>