项目作者: unlayer

项目描述 :
Drag-n-Drop Email Editor Component for Vue.js
高级语言: Vue
项目地址: git://github.com/unlayer/vue-email-editor.git
创建时间: 2018-11-03T20:13:11Z
项目社区:https://github.com/unlayer/vue-email-editor

开源协议:

下载


Vue Email Editor

The excellent drag-n-drop email editor by Unlayer as a Vue wrapper component. This is the most powerful and developer friendly visual email builder for your app.

Video Overview
Vue Email Editor
Watch video overview: https://youtu.be/MIWhX-NF3j8

Live Demo

Check out the live demo here: https://vue-email-editor-demo.netlify.app/ (Source Code)

Installation

The easiest way to use Vue Email Editor is to install it from Npm or Yarn and include it in your own Vue build process.

  1. npm install vue-email-editor --save

or

  1. yarn add vue-email-editor

Usage

Next, you’ll need to import the Email Editor component to your app.

App.vue

  1. <template>
  2. <div id="app">
  3. <div class="container">
  4. <div id="bar">
  5. <h1>Vue Email Editor (Demo)</h1>
  6. <button v-on:click="saveDesign">Save Design</button>
  7. <button v-on:click="exportHtml">Export HTML</button>
  8. </div>
  9. <EmailEditor
  10. ref="emailEditor"
  11. v-on:load="editorLoaded"
  12. v-on:ready="editorReady"
  13. ></EmailEditor>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import { EmailEditor } from 'vue-email-editor';
  19. export default {
  20. name: 'app',
  21. components: {
  22. EmailEditor,
  23. },
  24. methods: {
  25. // called when the editor is created
  26. editorLoaded() {
  27. console.log('editorLoaded');
  28. // Pass the template JSON here
  29. // this.$refs.emailEditor.editor.loadDesign({});
  30. },
  31. // called when the editor has finished loading
  32. editorReady() {
  33. console.log('editorReady');
  34. },
  35. saveDesign() {
  36. this.$refs.emailEditor.editor.saveDesign((design) => {
  37. console.log('saveDesign', design);
  38. });
  39. },
  40. exportHtml() {
  41. this.$refs.emailEditor.editor.exportHtml((data) => {
  42. console.log('exportHtml', data);
  43. });
  44. },
  45. },
  46. };
  47. </script>

Methods

method params description
loadDesign Object data Takes the design JSON and loads it in the editor
saveDesign Function callback Returns the design JSON in a callback function
exportHtml Function callback Returns the design HTML and JSON in a callback function

See the example source for a reference implementation.

Properties

  • editorId String HTML div id of the container where the editor will be embedded (optional)
  • minHeight String minimum height to initialize the editor with (default 500px)
  • options Object options passed to the Unlayer editor instance (default {})
  • tools Object configuration for the built-in and custom tools (default {})
  • appearance Object configuration for appearance and theme (default {})
  • projectId Integer Unlayer project ID (optional)
  • locale String translations string (default en-US)

See the Unlayer Docs for all available options.

Here’s an example using the above properties…

App.vue

  1. <template>
  2. <div id="app">
  3. <div class="container">
  4. <div id="bar">
  5. <h1>Vue Email Editor (Demo)</h1>
  6. <button v-on:click="saveDesign">Save Design</button>
  7. <button v-on:click="exportHtml">Export HTML</button>
  8. </div>
  9. <EmailEditor
  10. :appearance="appearance"
  11. :min-height="minHeight"
  12. :project-id="projectId"
  13. :locale="locale"
  14. :tools="tools"
  15. :options="options"
  16. ref="emailEditor"
  17. v-on:load="editorLoaded"
  18. v-on:ready="editorReady"
  19. ></EmailEditor>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { EmailEditor } from 'vue-email-editor';
  25. export default {
  26. name: 'app',
  27. components: {
  28. EmailEditor,
  29. },
  30. data() {
  31. return {
  32. minHeight: '1000px',
  33. locale: 'en',
  34. projectId: 0, // replace with your project id
  35. tools: {
  36. // disable image tool
  37. image: {
  38. enabled: false,
  39. },
  40. },
  41. options: {},
  42. appearance: {
  43. theme: 'dark',
  44. panels: {
  45. tools: {
  46. dock: 'right',
  47. },
  48. },
  49. },
  50. };
  51. },
  52. methods: {
  53. // called when the editor is created
  54. editorLoaded() {
  55. console.log('editorLoaded');
  56. // Pass your template JSON here
  57. // this.$refs.emailEditor.editor.loadDesign({});
  58. },
  59. // called when the editor has finished loading
  60. editorReady() {
  61. console.log('editorReady');
  62. },
  63. saveDesign() {
  64. this.$refs.emailEditor.editor.saveDesign((design) => {
  65. console.log('saveDesign', design);
  66. });
  67. },
  68. exportHtml() {
  69. this.$refs.emailEditor.editor.exportHtml((data) => {
  70. console.log('exportHtml', data);
  71. });
  72. },
  73. },
  74. };
  75. </script>

Custom Tools

Custom tools can help you add your own content blocks to the editor. Every application is different and needs different tools to reach it’s full potential. Learn More

Custom Tools

Localization

You can submit new language translations by creating a PR on this GitHub repo: https://github.com/unlayer/translations. Translations managed by PhraseApp

License

Copyright (c) 2024 Unlayer. MIT Licensed.