Open RezaErfani67 opened 2 years ago
I had the same problem, but I solved it.
First, create QuillEditor
wrapper component
// components/QuillEditorWrapper.client.vue <-- important!
<template>
<QuillEditor :modules="modules" toolbar="full" />
</template>
<script>
import ImageUploader from "quill-image-uploader";
export default {
setup: () => {
const modules = {
name: "imageUploader",
module: ImageUploader,
options: {
upload: (file) => {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append("image", file);
$fetch
.post("/upload-image", formData)
.then((res) => {
console.log(res);
resolve(res.data.url);
})
.catch((err) => {
reject("Upload failed");
console.error("Error:", err);
});
});
},
},
};
return { modules };
},
};
</script>
Second, use QuillEditorWrapper
component
// pages/index.vue
<template>
<QuillEditorWrapper/>
</template>
this is useful, but sometimes this tip 'document is not found' may still exist, you can just adjust the component introduction method.
I am facing: document is not defined
. My component is named Quill.client.vue
. What am I doing wrong here?
This is my code:
<template>
<QuillEditor :modules="modules" toolbar="full" />
</template>
<script>
import { QuillEditor } from '@vueup/vue-quill'
import ImageUploader from "quill-image-uploader";
export default {
setup: () => {
const modules = {
name: "imageUploader",
module: ImageUploader,
options: {
upload: (file) => {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append("image", file);
$fetch
.post("/upload-image", formData)
.then((res) => {
console.log(res);
resolve(res.data.url);
})
.catch((err) => {
reject("Upload failed");
console.error("Error:", err);
});
});
},
},
};
return { modules };
},
components: {
QuillEditor,
},
};
</script>
i am adding quill as client plugin and it works good but i cant add this module for it:
QuillEditor.client.ts
main component code: