markdown.html.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
  2. <?php
  3. $module = $this->moduleName;
  4. $method = $this->methodName;
  5. if(!isset($config->$module->markdown->$method)) return;
  6. $editor = $config->$module->markdown->$method;
  7. $editor['id'] = explode(',', $editor['id']);
  8. ?>
  9. <?php css::import($jsRoot . "markdown/simplemde.min.css");?>
  10. <?php js::import($jsRoot . 'markdown/simplemde.min.js'); ?>
  11. <style>
  12. .CodeMirror,.CodeMirror-scroll{min-height:200px!important;}
  13. .editor-preview-side table > tbody > tr:last-child td{border:1px solid #e5e5e5 !important}
  14. .editor-toolbar {padding: 1px;}
  15. .editor-toolbar .icon-html:before {content:"HTML"; font-size: 12px; padding: 0 2px;}
  16. .editor-toolbar .icon:before {font-size: 14px;}
  17. .editor-toolbar a.icon:before {line-height: 22px;}
  18. .editor-toolbar a {opacity: 0.8}
  19. .editor-toolbar a:hover {opacity: 1}
  20. .icon-bold:before {content: '\e953';}
  21. .icon-italic:before {content: '\e955';}
  22. .icon-header:before {content: '\e954';}
  23. .icon-quote-left:before {content: '\e96a';}
  24. .icon-list-ul:before {content: '\e956';}
  25. .icon-list-ol:before {content: '\e969';}
  26. .icon-picture:before {content: '\e96c';}
  27. .icon-table:before {content: '\e96d';}
  28. .icon-eye-open:before {content: '\e94e';}
  29. .icon-columns:before {content: '\f0db';}
  30. .icon-expand-full:before {content: '\e96b';}
  31. .icon-question-sign:before {content: '\e968';}
  32. </style>
  33. <script>
  34. $(function()
  35. {
  36. var markdownEditor = <?php echo json_encode($editor);?>;
  37. const customFullscreen =
  38. {
  39. name: 'fullscreen',
  40. className: 'icon icon-expand-full',
  41. title: 'Fullscreen',
  42. action: function(editor)
  43. {
  44. editor.toggleFullScreen();
  45. if(editor.isFullscreenActive() && !editor.isSideBySideActive())
  46. {
  47. editor.toggleSideBySide();
  48. }
  49. }
  50. };
  51. var toolbar = ["bold", "italic", "heading", "|", "quote", "unordered-list", "ordered-list", "|", "link", "image", "code", "table", "|", "preview", "side-by-side", customFullscreen, "|", "guide"];
  52. var withchange = ["bold", "italic", "heading", "|", "quote", "unordered-list", "ordered-list", "|", "link", "image", "code", "table", "|", "preview", "side-by-side", customFullscreen, "|", "guide", {name: "html", action: function customFunction(editor){toggleEditor && toggleEditor("html")}, className:'icon icon-html', title:"HTML"}];
  53. function initMarkdown(config, afterInit)
  54. {
  55. config = config || markdownEditor;
  56. $.each(markdownEditor.id, function(key, markdownEditorID)
  57. {
  58. if(typeof(markdownEditor.tools) != 'undefined' && markdownEditor.tools == 'withchange') toolbar = withchange;
  59. var options =
  60. {
  61. toolbar: toolbar,
  62. element: $('#' + markdownEditorID)[0],
  63. status: false,
  64. spellChecker: false,
  65. forceSync: true,
  66. renderingConfig: {markedOptions: {smartLists: false}}
  67. };
  68. var markdown = new SimpleMDE(options);
  69. if(!window.markdownEditor) window.markdownEditor = {};
  70. window.markdownEditor['#'] = window.markdownEditor[markdownEditorID] = markdown;
  71. });
  72. if($.isFunction(afterInit)) afterInit();
  73. }
  74. window.initMarkdown = initMarkdown;
  75. initMarkdown();
  76. });
  77. </script>