easymde_controller.js 915 B

12345678910111213141516171819202122232425262728
  1. import { Controller } from '@hotwired/stimulus';
  2. export default class extends Controller {
  3. connect() {
  4. const textarea = document.querySelector('textarea')
  5. const basePath = textarea.dataset.url
  6. const easyMde = new EasyMDE({
  7. element: textarea,
  8. spellChecker: false,
  9. toolbar: [
  10. 'bold', 'italic', 'heading-2', 'heading-3', '|',
  11. 'quote', 'unordered-list', 'ordered-list', 'table', '|',
  12. 'link', 'image', 'upload-image' ,'|',
  13. 'preview', 'side-by-side', 'fullscreen', '|',
  14. 'undo', 'redo', '|',
  15. 'guide'
  16. ],
  17. uploadImage:true,
  18. imageUploadEndpoint: basePath + '/upload-image',
  19. imagePathAbsolute: false,
  20. imageMaxSize: 1024 * 1024 * 100,
  21. previewImagesInEditor: true,
  22. });
  23. }
  24. }