You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. <template lang='pug'>
  2. .editor-wysiwyg
  3. div(ref='editor')
  4. </template>
  5. <script>
  6. import 'grapesjs/dist/css/grapes.min.css'
  7. import grapesjs from 'grapesjs'
  8. let editor
  9. export default {
  10. mounted() {
  11. editor = grapesjs.init({
  12. container: this.$refs.editor,
  13. width: 'auto',
  14. height: 'calc(100vh - 64px)',
  15. storageManager: { type: null },
  16. // panels: { defaults: [] }
  17. blockManager: {
  18. blocks: [
  19. {
  20. id: 'section', // id is mandatory
  21. label: '<b>Section</b>', // You can use HTML/SVG inside labels
  22. attributes: { class: 'gjs-block-section' },
  23. content: `<section>
  24. <h1>This is a simple title</h1>
  25. <div>This is just a Lorem text: Lorem ipsum dolor sit amet</div>
  26. </section>`
  27. }, {
  28. id: 'text',
  29. label: 'Text',
  30. content: '<div data-gjs-type="text">Insert your text here</div>',
  31. }, {
  32. id: 'image',
  33. label: 'Image',
  34. // Select the component once it's dropped
  35. select: true,
  36. // You can pass components as a JSON instead of a simple HTML string,
  37. // in this case we also use a defined component type `image`
  38. content: { type: 'image' },
  39. // This triggers `active` event on dropped components and the `image`
  40. // reacts by opening the AssetManager
  41. activate: true
  42. }
  43. ]
  44. }
  45. })
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .gjs-block {
  51. width: auto;
  52. height: auto;
  53. min-height: auto;
  54. }
  55. </style>