use-seajs.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Using sea.js - Editor.md examples</title>
  6. <link rel="stylesheet" href="css/style.css" />
  7. <link rel="stylesheet" href="../css/editormd.min.css" />
  8. <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
  9. <style>
  10. header p code {
  11. padding: 3px;
  12. border: 1px solid #ddd;
  13. background: #f6f6f6;
  14. border-radius: 3px;
  15. font-size: 85%;
  16. font-family: Consolas, 'Monaco', courier, monospace;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div id="layout">
  22. <header>
  23. <h1>Using sea.js</h1>
  24. <p>说明:</p>
  25. <p>1、由于Editor.md是依赖jQuery的,所以在使用Sea.js加载Editor.md时,要在jQuery.js文件尾部加上 <code>if(typeof define === "function") { define(function () { return $.noConflict(); }); }</code>,使jQuery支持Sea.js;</p>
  26. <p>2、flowChart(流程图)和sequenceDiagram(时序图)基于Raphael.js,由于疑似Sea.js与Raphael.js有冲突,所以必须先加载Raphael.js再加载Sea.js,Editor.md才能在Sea.js下正常进行;</p>
  27. <ul style="margin: 10px 0 0 18px;">
  28. <li>Enable HTML tags decode</li>
  29. <li>Enable TeX, Flowchart, Sequence Diagram, Emoji, FontAwesome, Task lists</li>
  30. <li>Enable Image upload</li>
  31. <li>Enable [TOCM], Search Replace, Code fold</li>
  32. </ul>
  33. </header>
  34. <div class="btns">
  35. <button id="show-btn">Show editor</button>
  36. <button id="hide-btn">Hide editor</button>
  37. <button id="get-md-btn">Get Markdown</button>
  38. <button id="get-html-btn">Get HTML</button>
  39. <button id="watch-btn">Watch</button>
  40. <button id="unwatch-btn">Unwatch</button>
  41. <button id="preview-btn">Preview HTML (Press Shift + ESC cancel)</button>
  42. <button id="fullscreen-btn">Fullscreen (Press ESC cancel)</button>
  43. <button id="show-toolbar-btn">Show toolbar</button>
  44. <button id="close-toolbar-btn">Hide toolbar</button>
  45. <button id="toc-menu-btn">ToC Dropdown menu</button>
  46. <button id="toc-default-btn">ToC default</button>
  47. </div>
  48. <div id="test-editormd"></div>
  49. </div>
  50. <!-- Flowchart & Sequence Diagram based on Raphael.js, and must load Raphael.js of Sea.js before. -->
  51. <script src="../lib/raphael.min.js"></script>
  52. <script src="js/sea.js"></script>
  53. <script type="text/javascript">
  54. seajs.config({
  55. base : "./",
  56. alias : {
  57. jquery : "js/jquery.min",
  58. editormd : "../editormd"
  59. }
  60. });
  61. //seajs.use("./js/seajs-main"); //使用main.js时 editormd 路径要改为 "../../editormd"
  62. var deps = [
  63. "jquery",
  64. "editormd",
  65. "../languages/en",
  66. "../plugins/link-dialog/link-dialog",
  67. "../plugins/reference-link-dialog/reference-link-dialog",
  68. "../plugins/image-dialog/image-dialog",
  69. "../plugins/code-block-dialog/code-block-dialog",
  70. "../plugins/table-dialog/table-dialog",
  71. "../plugins/emoji-dialog/emoji-dialog",
  72. "../plugins/goto-line-dialog/goto-line-dialog",
  73. "../plugins/help-dialog/help-dialog",
  74. "../plugins/html-entities-dialog/html-entities-dialog",
  75. "../plugins/preformatted-text-dialog/preformatted-text-dialog"
  76. ];
  77. seajs.use(deps, function($, editormd) {
  78. var testEditor;
  79. $.get("./test.md", function(md){
  80. testEditor = editormd("test-editormd", {
  81. width: "90%",
  82. height: 640,
  83. path : '../lib/',
  84. markdown : md,
  85. //toolbar : false, // 关闭工具栏
  86. codeFold : true,
  87. searchReplace : true,
  88. saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
  89. htmlDecode : "style,script,iframe|on*", // 开启 HTML 标签解析,为了安全性,默认不开启
  90. emoji : true,
  91. taskList : true,
  92. tocm : true, // Using [TOCM]
  93. tex : true, // 开启科学公式 TeX 语言支持,默认关闭
  94. //previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
  95. flowChart : true, // 疑似 Sea.js与 Raphael.js 有冲突,必须先加载 Raphael.js ,Editor.md 才能在 Sea.js 下正常进行;
  96. sequenceDiagram : true, // 同上
  97. //dialogLockScreen : false, // 设置弹出层对话框不锁屏,全局通用,默认为 true
  98. //dialogShowMask : false, // 设置弹出层对话框显示透明遮罩层,全局通用,默认为 true
  99. //dialogDraggable : false, // 设置弹出层对话框不可拖动,全局通用,默认为 true
  100. //dialogMaskOpacity : 0.4, // 设置透明遮罩层的透明度,全局通用,默认值为 0.1
  101. //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色,全局通用,默认为 #fff
  102. imageUpload : true,
  103. imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
  104. imageUploadURL : "./php/upload.php",
  105. onload : function() {
  106. console.log('onload', this);
  107. //this.fullscreen();
  108. //this.unwatch();
  109. //this.watch().fullscreen();
  110. //this.setMarkdown("#PHP");
  111. //this.width("100%");
  112. //this.height(480);
  113. //this.resize("100%", 640);
  114. }
  115. });
  116. });
  117. $("#show-btn").bind('click', function(){
  118. testEditor.show();
  119. });
  120. $("#hide-btn").bind('click', function(){
  121. testEditor.hide();
  122. });
  123. $("#get-md-btn").bind('click', function(){
  124. alert(testEditor.getMarkdown());
  125. });
  126. $("#get-html-btn").bind('click', function() {
  127. alert(testEditor.getHTML());
  128. });
  129. $("#watch-btn").bind('click', function() {
  130. testEditor.watch();
  131. });
  132. $("#unwatch-btn").bind('click', function() {
  133. testEditor.unwatch();
  134. });
  135. $("#preview-btn").bind('click', function() {
  136. testEditor.previewing();
  137. });
  138. $("#fullscreen-btn").bind('click', function() {
  139. testEditor.fullscreen();
  140. });
  141. $("#show-toolbar-btn").bind('click', function() {
  142. testEditor.showToolbar();
  143. });
  144. $("#close-toolbar-btn").bind('click', function() {
  145. testEditor.hideToolbar();
  146. });
  147. $("#toc-menu-btn").click(function(){
  148. testEditor.config({
  149. tocDropdown : true,
  150. tocTitle : "目录 Table of Contents",
  151. });
  152. });
  153. $("#toc-default-btn").click(function() {
  154. testEditor.config("tocDropdown", false);
  155. });
  156. });
  157. </script>
  158. </body>
  159. </html>