quill-image-drop-module icon indicating copy to clipboard operation
quill-image-drop-module copied to clipboard

copy img dom but paste twice

Open unliar opened this issue 7 years ago • 4 comments

move your mouse on a picture in chrome , use the right-click mouse menu option, copy img, then paste into editor,two different img src will show. one img src is Original source , another is base64 data.

env: chrome, https://plnkr.co/edit/ubVmPkBjqQESsefM3JrT?p=preview win10

unliar avatar Sep 05 '17 03:09 unliar

I guess because there is no evt.preventDefault(); after line 57. Which browsers need the image paste functionality, since it seems the Chrome (v 63.0.3239.132) handles pasting.

bwbroersma avatar Jan 29 '18 11:01 bwbroersma

Is there a solution for this? Adding evt.preventDefault() after line 57 does not work.

frankyvij avatar Jun 01 '18 06:06 frankyvij

I actually made it work by wrapping changing handlePaste function to the following:

    handlePaste(evt) {
        evt.preventDefault();

        if (evt.clipboardData && evt.clipboardData.items && evt.clipboardData.items.length) {
            this.readFiles(evt.clipboardData.items, dataUrl => {
                setTimeout(() => this.insert(dataUrl), 0);
            });
        }
    }

frankyvij avatar Jun 01 '18 06:06 frankyvij

@frankyvij I can confirm, I had similar problem, see the resulting dom:

image

I also had to comment out selection checking line 50 - the problem was that quill returned selection as an object with valid index and insert was never called. Therefore I use same code as @frankyvij .

Browser user agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"

chiptoe avatar Dec 16 '21 22:12 chiptoe