page-demo.js 963 B

12345678910111213141516171819202122232425262728
  1. (function() {
  2. $(function() {
  3. var $preview, editor, mobileToolbar, toolbar;
  4. Simditor.locale = 'en-US';
  5. toolbar = ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment'];
  6. mobileToolbar = ["bold", "underline", "strikethrough", "color", "ul", "ol"];
  7. if (mobilecheck()) {
  8. toolbar = mobileToolbar;
  9. }
  10. editor = new Simditor({
  11. textarea: $('#txt-content'),
  12. placeholder: '这里输入文字...',
  13. toolbar: toolbar,
  14. pasteImage: true,
  15. defaultImage: 'assets/images/image.png',
  16. upload: location.search === '?upload' ? {
  17. url: '/upload'
  18. } : false
  19. });
  20. $preview = $('#preview');
  21. if ($preview.length > 0) {
  22. return editor.on('valuechanged', function(e) {
  23. return $preview.html(editor.getValue());
  24. });
  25. }
  26. });
  27. }).call(this);