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
I was trying to implement a custom handler for image loading, which gave me the following error:
quill.js?v=ad3ea11b:12611 Uncaught TypeError: Cannot read properties of null (reading 'offset')
at quill.js?v=ad3ea11b:12611:26
at Array.map ()
at Proxy.normalizedToRange (quill.js?v=ad3ea11b:12608:31)
at Proxy.getRange (quill.js?v=ad3ea11b:12597:25)
at Proxy.update (quill.js?v=ad3ea11b:12734:43)
at Proxy.update (quill.js?v=ad3ea11b:13811:20)
at Proxy.getSelection (quill.js?v=ad3ea11b:13705:10)
at Toolbar.imageHandler (EditPublicationPage.vue:42:31)
at HTMLButtonElement. (quill.js?v=ad3ea11b:17165:31)
I downgraded to 1.3.7 from 2.0.2 (also tested 2.0.1 and 2.0.0 with no success) and the same code now works flawlessly.
The Handler:
function imageHandler () {
if (quill.value) {
quill.value.focus() const range = quill.value.getSelection() // this line throws error
const value = prompt('please copy paste the image url here.')
if (value) {
quill.value.insertEmbed(range.index, 'image', value, Quill.sources.USER)
}
}
}
I was trying to implement a custom handler for image loading, which gave me the following error:
quill.js?v=ad3ea11b:12611 Uncaught TypeError: Cannot read properties of null (reading 'offset')
at quill.js?v=ad3ea11b:12611:26
at Array.map ()
at Proxy.normalizedToRange (quill.js?v=ad3ea11b:12608:31)
at Proxy.getRange (quill.js?v=ad3ea11b:12597:25)
at Proxy.update (quill.js?v=ad3ea11b:12734:43)
at Proxy.update (quill.js?v=ad3ea11b:13811:20)
at Proxy.getSelection (quill.js?v=ad3ea11b:13705:10)
at Toolbar.imageHandler (EditPublicationPage.vue:42:31)
at HTMLButtonElement. (quill.js?v=ad3ea11b:17165:31)
I downgraded to 1.3.7 from 2.0.2 (also tested 2.0.1 and 2.0.0 with no success) and the same code now works flawlessly.
The Handler:
function imageHandler () {
if (quill.value) {
quill.value.focus()
const range = quill.value.getSelection() // this line throws error
const value = prompt('please copy paste the image url here.')
if (value) {
quill.value.insertEmbed(range.index, 'image', value, Quill.sources.USER)
}
}
}
all source code of my component:
``
<script setup lang="ts"> import { ref } from 'vue' import Editor, { EditorLoadEvent } from 'primevue/editor' import Quill from 'quill' const richContent = ref('') const toolbarOptions = [ ['bold', 'italic', 'underline', 'strike'], // toggled buttons ['blockquote', 'code-block'], ['link', 'image', 'video', 'formula'], [{ list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], [{ script: 'sub' }, { script: 'super' }], // superscript/subscript [{ indent: '-1' }, { indent: '+1' }], // outdent/indent [{ size: ['small', false, 'large', 'huge'] }], [{ color: [] }, { background: [] }], // dropdown with defaults from theme [{ font: [] }], [{ align: [] }], ['clean'] // remove formatting button ] const quillModules = { toolbar: { container: toolbarOptions, handlers: { image: imageHandler } } } const quill = ref(null) function onLoadEditor (event: EditorLoadEvent) { quill.value = event.instance } function imageHandler () { if (quill.value) { quill.value.focus() const range = quill.value.getSelection() const value = prompt('please copy paste the image url here.') if (value) { quill.value.insertEmbed(range.index, 'image', value, Quill.sources.USER) } } } </script>``
The text was updated successfully, but these errors were encountered: