quill-image-uploader icon indicating copy to clipboard operation
quill-image-uploader copied to clipboard

Uploading image is trimming characters again

Open DvzH opened this issue 4 years ago • 2 comments

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.

DvzH avatar Jul 02 '20 09:07 DvzH

+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?

pra7eek avatar Aug 03 '20 05:08 pra7eek

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.

pedropalhari avatar Sep 20 '20 17:09 pedropalhari