Vue-quill-editor get cannot get cursor position

vue-quill-editor get cannot get cursor position

let quill = this.$refs.myQuillEditor.quill
/ / if the upload is successful
if (rets = "lyck" & & rets! = = null) {
/ if the upload is successful
/ / get the location of the cursor
let length = quill.getSelection () .index
/ / insert the image address returned by the server res.url
quill.insertEmbed (length," image", result)
/ / adjust the cursor to the last
quill.setSelection (length + 1)

let quill = this.$refs.myQuillEditor.quill the value of quill that failed to get an instance of a rich text component is undefined

Jan.17,2022
In the

project, the cursor position is mainly the index value in range
this.$refs.myQuillEditor.quill. selection.savedRange.index to get the cursor position


because the content area of your rich text editor has no content, and there is a quill.getSelection () function if there is content. Otherwise, the value of quill.getSelection () is undefined


the event of getting the cursor. You can write on button and try other elements.


how to upgrade the quill dependency of vue-quill-editor

Menu