You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example I am gonna use [quill-image-uploader](https://github.com/NoelOConnell/quill-image-uploader), A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded.
46
+
47
+
48
+
**Installation:**
49
+
```bash
50
+
npm install quill-image-uploader --save
51
+
```
52
+
**Usage:**
53
+
54
+
~~~vue
55
+
<template>
56
+
<QuillEditor :modules="modules" toolbar="full" />
57
+
</template>
58
+
59
+
<script>
60
+
import { ref, defineComponent } from 'vue'
61
+
import { QuillEditor } from '@vueup/vue-quill'
62
+
import '@vueup/vue-quill/dist/vue-quill.snow.css'
63
+
import ImageUploader from 'quill-image-uploader';
64
+
import axios from '../lib/axios';
65
+
66
+
export default defineComponent({
67
+
components: {
68
+
QuillEditor,
69
+
},
70
+
setup: () => {
71
+
const modules = {
72
+
name: 'imageUploader',
73
+
module: ImageUploader,
74
+
options: {
75
+
upload: file => {
76
+
return new Promise((resolve, reject) => {
77
+
const formData = new FormData();
78
+
formData.append("image", file);
79
+
80
+
axios.post('/upload-image', formData)
81
+
.then(res => {
82
+
console.log(res)
83
+
resolve(res.data.url);
84
+
})
85
+
.catch(err => {
86
+
reject("Upload failed");
87
+
console.error("Error:", err)
88
+
})
89
+
})
90
+
}
91
+
return { modules }
92
+
}
93
+
})
94
+
</script>
95
+
~~~
44
96
45
97
See [Quill modules docs](https://quilljs.com/docs/modules/) for more details.
0 commit comments