themes.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Themes - 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. /* Custom Editor.md theme css example */
  11. /*
  12. .editormd-theme-dark {
  13. border-color: #1a1a17;
  14. }
  15. .editormd-theme-dark .editormd-toolbar {
  16. background: #1A1A17;
  17. border-color: #1a1a17;
  18. }
  19. .editormd-theme-dark .editormd-menu > li > a {
  20. color: #777;
  21. border-color: #1a1a17;
  22. }
  23. .editormd-theme-dark .editormd-menu > li.divider {
  24. border-right: 1px solid #111;
  25. }
  26. .editormd-theme-dark .editormd-menu > li > a:hover, .editormd-menu > li > a.active {
  27. border-color: #333;
  28. background: #333;
  29. }*/
  30. </style>
  31. </head>
  32. <body>
  33. <div id="layout">
  34. <header>
  35. <h1>Themes</h1>
  36. <p>
  37. <select id="editormd-theme-select">
  38. <option selected="selected" value="">select Editor.md themes</option>
  39. </select>
  40. <select id="editor-area-theme-select">
  41. <option selected="selected" value="">select editor area themes</option>
  42. </select>
  43. <select id="preview-area-theme-select">
  44. <option selected="selected" value="">select preview area themes</option>
  45. </select>
  46. </p>
  47. </header>
  48. <div id="test-editormd">
  49. <textarea style="display:none;">[TOC]
  50. ### Themes
  51. #### Setting
  52. configs:
  53. ```javascript
  54. {
  55. // Editor.md theme, default or dark, change at v1.5.0
  56. // You can also custom css class .editormd-theme-xxxx
  57. theme : "default | dark",
  58. // Preview container theme, added v1.5.0
  59. // You can also custom css class .editormd-preview-theme-xxxx
  60. previewTheme : "default | dark",
  61. // Added @v1.5.0 & after version this is CodeMirror (editor area) theme
  62. editorTheme : editormd.editorThemes['theme-name']
  63. }
  64. ```
  65. functions:
  66. ```javascript
  67. editor.setTheme('theme-name');
  68. editor.setEditorTheme('theme-name');
  69. editor.setPreviewTheme('theme-name');
  70. ```
  71. #### Default theme
  72. - Editor.md theme : `default`
  73. - Preview area theme : `default`
  74. - Editor area theme : `default`
  75. > Recommend `dark` theme.
  76. #### Recommend editor area themes
  77. - ambiance
  78. - eclipse
  79. - mdn-like
  80. - mbo
  81. - monokai
  82. - neat
  83. - pastel-on-dark
  84. #### Editor area themes
  85. - default
  86. - 3024-day
  87. - 3024-night
  88. - ambiance
  89. - ambiance-mobile
  90. - base16-dark
  91. - base16-light
  92. - blackboard
  93. - cobalt
  94. - eclipse
  95. - elegant
  96. - erlang-dark
  97. - lesser-dark
  98. - mbo
  99. - mdn-like
  100. - midnight
  101. - monokai
  102. - neat
  103. - neo
  104. - night
  105. - paraiso-dark
  106. - paraiso-light
  107. - pastel-on-dark
  108. - rubyblue
  109. - solarized
  110. - the-matrix
  111. - tomorrow-night-eighties
  112. - twilight
  113. - vibrant-ink
  114. - xq-dark
  115. - xq-light
  116. </textarea>
  117. </div>
  118. </div>
  119. <script src="js/jquery.min.js"></script>
  120. <script src="../editormd.js"></script>
  121. <script type="text/javascript">
  122. var testEditor;
  123. function themeSelect(id, themes, lsKey, callback)
  124. {
  125. var select = $("#" + id);
  126. for (var i = 0, len = themes.length; i < len; i ++)
  127. {
  128. var theme = themes[i];
  129. var selected = (localStorage[lsKey] == theme) ? " selected=\"selected\"" : "";
  130. select.append("<option value=\"" + theme + "\"" + selected + ">" + theme + "</option>");
  131. }
  132. select.bind("change", function(){
  133. var theme = $(this).val();
  134. if (theme === "")
  135. {
  136. alert("theme == \"\"");
  137. return false;
  138. }
  139. console.log("lsKey =>", lsKey, theme);
  140. localStorage[lsKey] = theme;
  141. callback(select, theme);
  142. });
  143. return select;
  144. }
  145. $(function() {
  146. testEditor = editormd("test-editormd", {
  147. width : "90%",
  148. height : 720,
  149. // Editor.md theme, default or dark, change at v1.5.0
  150. // You can also custom css class .editormd-preview-theme-xxxx
  151. theme : (localStorage.theme) ? localStorage.theme : "dark",
  152. // Preview container theme, added v1.5.0
  153. // You can also custom css class .editormd-preview-theme-xxxx
  154. previewTheme : (localStorage.previewTheme) ? localStorage.previewTheme : "dark",
  155. // Added @v1.5.0 & after version is CodeMirror (editor area) theme
  156. editorTheme : (localStorage.editorTheme) ? localStorage.editorTheme : "pastel-on-dark",
  157. path : '../lib/'
  158. });
  159. themeSelect("editormd-theme-select", editormd.themes, "theme", function($this, theme) {
  160. testEditor.setTheme(theme);
  161. });
  162. themeSelect("editor-area-theme-select", editormd.editorThemes, "editorTheme", function($this, theme) {
  163. testEditor.setCodeMirrorTheme(theme);
  164. // or testEditor.setEditorTheme(theme);
  165. });
  166. themeSelect("preview-area-theme-select", editormd.previewThemes, "previewTheme", function($this, theme) {
  167. testEditor.setPreviewTheme(theme);
  168. });
  169. });
  170. </script>
  171. </body>
  172. </html>