Created
May 16, 2017 10:28
-
-
Save devyfriend/4bdcde471358f2374a98a63f8f9faac2 to your computer and use it in GitHub Desktop.
vue + quilljs + image resize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template lang="html"> | |
| <div id="editor"> | |
| <quill-editor | |
| class="editor-example" | |
| ref="myQuillEditor" | |
| :content="content" | |
| :options="editorOption" | |
| @change="onEditorChange($event)"> | |
| </quill-editor> | |
| </div> | |
| </template> | |
| <script> | |
| import Quill from 'quill' | |
| let ImageResize = require('quill-image-resize-module/image-resize.min.js').default | |
| Quill.register('modules/imageResize', ImageResize) | |
| let ImageDrop = require('quill-image-drop-module/image-drop.min.js').default | |
| import Vue from 'vue' | |
| import VueQuillEditor from 'vue-quill-editor' | |
| Vue.use(VueQuillEditor) | |
| export default { | |
| data() { | |
| return { | |
| content: 'I am Example', | |
| editorOption: { | |
| theme: 'bubble', placeholder: "...", | |
| modules: { | |
| toolbar: [ | |
| [ 'bold', 'italic', 'underline', 'strike',{'header': [2, 3, false]} ], | |
| [ {'list': 'ordered'},{'list': 'bullet'},{'align': [] } ], | |
| [ 'link', 'image' ], [ 'clean' ] | |
| ], | |
| imageResize: { | |
| modules: [ 'Resize', 'DisplaySize', 'Toolbar' ] | |
| // displaySize: true | |
| }, | |
| imageDrop: true | |
| } | |
| } | |
| } | |
| }, | |
| methods: { | |
| onEditorBlur(editor) {}, | |
| onEditorFocus(editor) {}, | |
| onEditorReady(editor) {}, | |
| onEditorChange({ editor, html, text }) { | |
| this.content = html | |
| } | |
| }, | |
| computed: { | |
| editor() { | |
| return this.$refs.myQuillEditor.quill | |
| } | |
| }, | |
| created(){ | |
| }, | |
| mounted() { | |
| window.$vm = this | |
| // console.log('this is current quill instance object', this.editor) | |
| } | |
| } | |
| </script> | |
| <style> | |
| .ql-bubble .ql-picker-label { padding-left:0 !important; } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment