npm install vue-wysiwyg --save
OR
yarn add vue-wysiwyg
In your main.js
:
import wysiwyg from "vue-wysiwyg";
Vue.use(wysiwyg, {}); // config is optional. more below
Also make sure to load the stylesheet. The exact syntax will depend on what preprocessor you use.
@import "~vue-wysiwyg/dist/vueWysiwyg.css";
In your components:
<wysiwyg v-model="myHTML" />
All keys are optional.
{
// { [module]: boolean (set true to hide) }
hideModules: { "bold": true },
// if the image option is not set, images are inserted as base64
image: {
uploadURL: "/api/myEndpoint",
dropzoneOptions: {}
},
// limit content height if you wish. If not set, editor size will grow with content.
maxHeight: "500px"
}
Available Modules:
- bold
- italic
- underline
- alignLeft
- alignCenter
- alignRight
- headings
- link
- code
- orderedList
- unorderedList
- image
- table
- removeFormat
Note on the image upload API endpoint:
- Image is uploaded by
multipart/form-data
- Your endpoint must respond back with a string, the URL for the image - e.g.
http://myapp.com/images/12345.jpg