mcguffin / the-paste

Paste Images in WordPress from many applications and upload them to the media library.
https://wordpress.org/plugins/the-paste/
GNU General Public License v3.0
40 stars 11 forks source link

Plugin incompatble with "instant images" plugin #40

Closed oferlaor closed 1 year ago

oferlaor commented 1 year ago

I patched it by wrapping this code with a try/catch:

               this.controller instanceof wp.media.view.MediaFrame.Select || wp.media.thepaste.supports.paste && (e = new wp.media.view.Button({
                            text: n.copy_paste,
                            className: "grabber-button",
                            priority: -64,
                            click: function () {
                                t.thepaste.active = t.thepaste.paste,
                                t.thepasteOpen(n.copy_paste)
                            }
                        }), this.thepaste.paste.grabber = new wp.media.thepaste.view.DataSourceImageGrabber({
                            controller: this.controller,
                            grabber: wp.media.thepaste.view.Pasteboard,
                            wpuploader: this.controller.uploader.uploader.uploader
                        }), this.toolbar.set("pasteModeButton", e.render()))

Here is the patched code:

                       ( function () {
                        try {
                            return this.controller instanceof wp.media.view.MediaFrame.Select || wp.media.thepaste.supports.paste && (e = new wp.media.view.Button({
                                text: n.copy_paste,
                                className: "grabber-button",
                                priority: -64,
                                click: function () {
                                    t.thepaste.active = t.thepaste.paste,
                                    t.thepasteOpen(n.copy_paste)
                                }
                            }), this.thepaste.paste.grabber = new wp.media.thepaste.view.DataSourceImageGrabber({
                                controller: this.controller,
                                grabber: wp.media.thepaste.view.Pasteboard,
                                wpuploader: this.controller.uploader.uploader.uploader
                            }), this.toolbar.set("pasteModeButton", e.render()))
                        } catch (e) {
                            return null;
                        }
                    })
mcguffin commented 1 year ago

Sorry … I can't reproduce this. What exactly are you are doing?

oferlaor commented 1 year ago

Sorry … I can't reproduce this.

What exactly are you are doing?

Install the plugin "instant images" in addition to the-paste.

Now open a post. Press insert media button and see that you get a console error.

oferlaor commented 1 year ago

the paste 1 You can see that "the paste" competes with instant images (https://wordpress.org/plugins/instant-images/) on the top button on the Add Media screen.

the paste 2 When both are present, going into the classic editor and pressing Add Media produces this error. the paste 3

mcguffin commented 1 year ago

Thanks! I can see: the Copy & Paste Tab is missing in the media library... I just released Version 2, bringing a revised UX concept and rewritten JS. No issues with Instant Images encountered so far... Fell free to close the issue, if it is fixed for you (or to come back if not).

oferlaor commented 1 year ago

I can't install version 2.0.1, getting this error:

wp-tinymce.js?ver=49110-20201110:3 Failed to initialize plugin: the_paste TypeError: Cannot read properties of undefined (reading 'options')
    at new n (the-paste-plugin.js?wp-mce-49110-20201110-tadv-5900:1:519)
    at Ew (wp-tinymce.js?ver=49110-20201110:3:330473)
    at Array.<anonymous> (wp-tinymce.js?ver=49110-20201110:3:332223)
    at Object.jt [as each] (wp-tinymce.js?ver=49110-20201110:3:29356)
    at Aw (wp-tinymce.js?ver=49110-20201110:3:332173)
    at tN.<anonymous> (wp-tinymce.js?ver=49110-20201110:3:333551)
    at Array.<anonymous> (wp-tinymce.js?ver=49110-20201110:3:96969)
    at jt (wp-tinymce.js?ver=49110-20201110:3:29356)
    at u (wp-tinymce.js?ver=49110-20201110:3:96914)
    at n (wp-tinymce.js?ver=49110-20201110:3:96402)
mcguffin commented 1 year ago

@see #45