-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't find variable: Quill when registering Quill modules #171
Comments
OK, so this seems to be an issue with how a Quill module is structured. The quill-image-drop-module, for example works out of the box. It seems some of the modules are registering the module with Quill themselves. I don’t see any alternative but to fork the modules in question and fix them to play better with workflows that involve Nuxt/Vue/etc. Closing this as it’s not an issue with vue-quill-editor but it would be good to make a note of this in the documentation as, no doubt, other people will run into the problem. Also, the Quill project should probably standardise on a compatible module distribution format, perhaps based on how quill-image-drop-module does it. |
(Ah, and quill-image-drop-module doesn’t use Webpack.) |
Re-opening this as it seems to be an issue that many people run into and it should, at the very least, be documented in the vue-quill-editor docs. For a comprehensive thread, with a workaround, see: kensnyder/quill-image-resize-module#7 We should document the solution at kensnyder/quill-image-resize-module#7 (comment) by @ibudisteanu |
The solution for installing plugins like quill-image-resize-module in a Nuxt/SSR app:
import Vue from 'vue'
import Quill from 'quill'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/imageResize', ImageResize)
Vue.use(VueQuillEditor)
module.exports = {
plugins: [
{ src: '~plugins/vue-quill-editor', ssr: false }
]
}
module.exports = {
build: {
plugins: [
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
})
]
}
}
<template>
<div>
<no-ssr>
<quill-editor
v-model='editorContent'
ref='textEditor'
:options='editorOption'
></quill-editor>
</no-ssr>
</div>
</template>
<script>
export default {
data () {
return {
editorContent: '',
editorOption: {
placeholder: 'What’s on your mind?',
theme: 'snow',
modules: {
imageResize: true
}
}
}
}
}
</script> |
@aral Thank you for the snippet, You saved me from hours of frustration! 1: in the plugin file import Vue from 'vue'
import VueQuillEditor, {Quill} from 'vue-quill-editor'
import ImageResize from 'quill-image-resize-module'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
Quill.register('modules/imageResize', ImageResize)
Vue.use(VueQuillEditor) 2: in nuxt.config.js var webpack = require('webpack') Thank you! |
Hey @mayowa, my pleasure. Glad to hear it helped and thank you for sharing your own experience also :) |
@aral hi is there a resolution for a spa app with webpack ? the resolution in kensnyder/quill-image-resize-module#7 given by jspaine doesn't work for me |
It works. Thanks a lot.. |
Hi. For a non SSR app (using Vue CLI 3) I am also having this same issue: Have I done something wrong here?
|
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js',
}), Added in webpack config. |
Okay so I was able to solve this problem for SPA apps by doing this:
var webpack = require('webpack');
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
}),
]
}
} What this does is it helps Vue import quill and help register the Image resize module
import Quill from 'quill'
import { ImageDrop } from 'quill-image-drop-module'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/imageDrop', ImageDrop)
Quill.register('modules/imageResize', ImageResize) and in the options for quill, make the modules true as such: editor_option: {
modules: {
imageDrop: true,
imageResize: true,
},
theme: 'snow'
}, and voila! The image resize and drop should work. |
Wonder if I could get a little help. I’ve been trying for weeks to get Vue-Quill-Editor running with Nuxt without much success. I’ve learned a lot on here but still ended up short. If I enable the nuxt-quill plugin I get a ‘hook’ error. If I don’t, I receive a ‘failed to resolve directive: Quill’ error. I’m running Nuxt 2. Thank you, Rick Here’s my code: Vue-config.js var webpack = require('webpack'); Nuxt-quill-plugin.js import Vue from 'vue' Main.scss .container { css:[ plugins: [ modules: [ Index.vue // Editor template script I am Example ',editorOption: { // some quill options modules: { toolbar: [ ['bold', 'italic', 'underline', 'strike'], ['blockquote', 'code-block'] ] } } } }, mounted() { console.log('app init, my quill insrance object is:', this.myQuillEditor) setTimeout(() => { this.content = 'i am changed' }, 3000) }, methods: { onEditorBlur(editor) { console.log('editor blur!', editor) }, onEditorFocus(editor) { console.log('editor focus!', editor) }, onEditorReady(editor) { console.log('editor ready!', editor) }, onEditorChange({ editor, html, text }) { console.log('editor change!', editor, html, text) this.content = html } } /script |
thanks, I resolved problems on quill-emoji.js by this way |
Could you send an example how you did it? |
thank you! image upload base64 -> url
|
Hi, Is there anyone implemented quill-better-table? Thanks |
@aral Have you used quill-emoji? I introduced this module without any error, but the emoji module cannot be displayed or work properly |
### qweqweqe
|
Hey, When I import |
This solution solved my problem! In nuxt.config.js
In plugins > nuxt-quill-plugin.js `import Vue from 'vue' import 'quill/dist/quill.core.css' Quill.register('modules/imageResize', ImageResize) |
BUG REPORT TEMPLATE
Vue.js version and component version
Nuxt 1.3.0, Vue 2.5.13
Reproduction Link
n/a (issue has to do with Quill module usage in Nuxt)
Steps to reproduce
In my Nuxt config, I have it set up so that Nuxt does not apply SSR:
What is Expected?
It should work.
What is actually happening?
Error: Can’t find variable: Quill.
I’ve documented how I managed to solve this for one module here: https://github.com/aral/quill-markdown-shortcuts-for-vue-quill-editor
However, I’ve just encountered the same issue on another component so I think there’s something inherently problematic with trying to use modules with Nuxt.
PS. If, instead of importing the script from the dist folder, I do
import Emoji from 'quill-emoji'
, I get:The text was updated successfully, but these errors were encountered: