seajs-main.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. define(function(require){
  2. var $ = require("jquery");
  3. var editormd = require("editormd");
  4. require("../../src/js/languages/en"); // 加载英语语言包
  5. console.log($, editormd);
  6. $.get("./test.md", function(md){
  7. testEditor = editormd("test-editormd", {
  8. width: "90%",
  9. height: 640,
  10. path : '../lib/',
  11. markdown : md,
  12. //toolbar : false, //关闭工具栏
  13. htmlDecode : true, // 开启HTML标签解析,为了安全性,默认不开启
  14. tex : true, // 开启科学公式TeX语言支持,默认关闭
  15. //previewCodeHighlight : false, // 关闭预览窗口的代码高亮,默认开启
  16. flowChart : true, // 疑似Sea.js与Raphael.js有冲突,必须先加载Raphael.js,Editor.md才能在Sea.js下正常进行;
  17. sequenceDiagram : true, // 同上
  18. onload : function() {
  19. console.log('onload', this);
  20. //this.fullscreen();
  21. //this.unwatch();
  22. //this.watch().fullscreen();
  23. //this.setMarkdown("#PHP");
  24. //this.width("100%");
  25. //this.height(480);
  26. //this.resize("100%", 640);
  27. }
  28. });
  29. });
  30. $("#show-btn").bind('click', function(){
  31. testEditor.show();
  32. });
  33. $("#hide-btn").bind('click', function(){
  34. testEditor.hide();
  35. });
  36. $("#get-md-btn").bind('click', function(){
  37. alert(testEditor.getMarkdown());
  38. });
  39. $("#get-html-btn").bind('click', function() {
  40. alert(testEditor.getHTML());
  41. });
  42. $("#watch-btn").bind('click', function() {
  43. testEditor.watch();
  44. });
  45. $("#unwatch-btn").bind('click', function() {
  46. testEditor.unwatch();
  47. });
  48. $("#preview-btn").bind('click', function() {
  49. testEditor.previewing();
  50. });
  51. $("#fullscreen-btn").bind('click', function() {
  52. testEditor.fullscreen();
  53. });
  54. $("#show-toolbar-btn").bind('click', function() {
  55. testEditor.showToolbar();
  56. });
  57. $("#close-toolbar-btn").bind('click', function() {
  58. testEditor.hideToolbar();
  59. });
  60. });