external-use.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>External use - 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>External use</h1>
  14. <p>External use of toolbar handlers / modal dialog</p>
  15. </header>
  16. <div class="btns">
  17. <button id="undo">Undo</button>
  18. <button id="open-link-dialog">Open link dialog</button>
  19. <button id="insert-bold">Insert Bold</button>
  20. <button id="insert-h6">Insert Heading 6</button>
  21. <button id="insert-inline-code">Insert Inline code</button>
  22. <button id="open-image-dialog">Open image dialog</button>
  23. <button id="open-help-dialog">Open help dialog</button>
  24. <button id="open-html-entities-dialog">Open html entities dialog</button>
  25. </div>
  26. <div id="test-editormd">
  27. <textarea style="display:none;">[TOC]
  28. ### External use of toolbar handlers / modal dialog
  29. ```javascript
  30. testEditor = editormd("test-editormd", {
  31. width : "90%",
  32. height : 720,
  33. path : '../lib/'
  34. });
  35. // the first method
  36. $("#undo").bind('click', function() {
  37. $.proxy(testEditor.toolbarHandlers.undo, testEditor)();
  38. });
  39. // the Second method : using manually loaded dialog plugin
  40. // &lt;script src="../plugins/html-entities/html-entities.js"&gt;&lt;/script&gt;
  41. $("#open-html-entities-dialog").bind('click', function() {
  42. testEditor.htmlEntities();
  43. });
  44. // using toolbar dialog plugin
  45. $("#open-link-dialog").bind('click', function() {
  46. $.proxy(testEditor.toolbarHandlers.link, testEditor)();
  47. });
  48. // or
  49. $("#open-image-dialog").bind('click', function(){
  50. // load and execute plugin
  51. testEditor.executePlugin("imageDialog", "../plugins/image-dialog/image-dialog");
  52. });
  53. ```
  54. </textarea>
  55. </div>
  56. </div>
  57. <script src="js/jquery.min.js"></script>
  58. <script src="../editormd.js"></script>
  59. <!-- manually load dialog plugin -->
  60. <script src="../plugins/html-entities-dialog/html-entities-dialog.js"></script>
  61. <script type="text/javascript">
  62. var testEditor;
  63. $(function() {
  64. testEditor = editormd("test-editormd", {
  65. width : "90%",
  66. height : 720,
  67. path : '../lib/'
  68. });
  69. // the first method
  70. $("#undo").bind('click', function() {
  71. $.proxy(testEditor.toolbarHandlers.undo, testEditor)();
  72. });
  73. // the Second method : using manually loaded dialog plugin
  74. $("#open-html-entities-dialog").bind('click', function() {
  75. testEditor.htmlEntitiesDialog();
  76. });
  77. $("#insert-bold").bind('click', function() {
  78. $.proxy(testEditor.toolbarHandlers.bold, testEditor)();
  79. testEditor.focus();
  80. });
  81. $("#insert-h6").bind('click', function() {
  82. $.proxy(testEditor.toolbarHandlers.h6, testEditor)();
  83. testEditor.focus();
  84. });
  85. $("#insert-inline-code").bind('click', function() {
  86. $.proxy(testEditor.toolbarHandlers.code, testEditor)();
  87. testEditor.focus();
  88. });
  89. $("#open-help-dialog").bind('click', function() {
  90. $.proxy(testEditor.toolbarHandlers.help, testEditor)();
  91. });
  92. // using toolbar dialog plugin
  93. $("#open-link-dialog").bind('click', function() {
  94. $.proxy(testEditor.toolbarHandlers.link, testEditor)();
  95. });
  96. // or
  97. $("#open-image-dialog").bind('click', function(){
  98. testEditor.executePlugin("imageDialog", "../plugins/image-dialog/image-dialog"); // load and execute plugin
  99. });
  100. });
  101. </script>
  102. </body>
  103. </html>