NoelOConnell/quill-image-uploader

Uploading image is trimming characters again

DvzH opened this issue · 2 comments

DvzH commented

Hi,
When I try to add the image at the beginning of the text editor, If there are already any texts/words are present then it will trim the first character of that word/texts. It happens only when we add an image in the beginning. It doesn't trim character if you add the image in the middle of some words/sentences or at the end of the words. This issue is already there in the sandbox code of the QuillImageUpload.

+1
I am also facing the same issue. Whenever there is an image added in the starting of the text editor, it trims the first character of the existing text.
Did you find any solution to this?

I don't know the long term implications of this, but I did a patch using patch-package on the following line:

    //line 158
    insertToEditor(url) {
        const range = this.range;
        // Delete the placeholder image
        //this.quill.deleteText(range.index, 3, "user"); <--- OLD TRIMMING CODE
        this.quill.deleteText(range.index, 1, "user");
        // Insert the server saved image
        this.quill.insertEmbed(range.index, "image", `${url}`, "user");

        range.index++;
        this.quill.setSelection(range, "user");
    }

So far it has fixed for our specific requirements.