chenjuneking / quill-image-drop-and-paste

A quill editor module for drop and paste image, with a callback hook before insert image into the editor
ISC License
105 stars 44 forks source link

Image drop issue #51

Closed gyang55 closed 1 month ago

gyang55 commented 10 months ago

When I dropped a first pic, it is fine. But when I want to drop a second pic after the first one, it was always dropped before the first pic and cannot be dropped after it.

chenjuneking commented 6 months ago

try to change the index on the custom image handler.

function imageHandler(imageDataUrl, type, imageData) {
    // ...
    let index = (quill.getSelection() || {}).index
    if (index === undefined || index < 0) index = quill.getLength()
    quill.insertEmbed(index, 'image', res.data.image_url, 'user')
}