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

2.0.1 and 2.0.2 are broken - The Paste doesn't load #45

Closed oferlaor closed 11 months ago

oferlaor commented 11 months ago

In classic editor (TinyMCE):

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)
Th @ wp-tinymce.js?ver=49110-20201110:3
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 Ri.loadScripts (wp-tinymce.js?ver=49110-20201110:3:97028)
mcguffin commented 11 months ago

I can't exactly reproduce it, but I may have an Idea what's going on: The tinyMCE plugin tries to loading before the main script. Can you do me a favor and add add_action( 'wp_enqueue_editor', [ $this, 'enqueue_assets' ] ); in https://github.com/mcguffin/the-paste/blob/master/include/ThePaste/Admin/Admin.php#L32 and try again?

oferlaor commented 11 months ago

So, when I added it, no error occurs.

I saw that you changed the behavior - I don't see the upload button on the toolbar anymore and I don't see the paste area in the media upload and that the name of the files now default to image.png instead of Pasted. I like the new changes, but were they intentional?

On Wed, Sep 27, 2023 at 8:46 AM Jörn Lund @.***> wrote:

I can't exactly reproduce it, but I may have an Idea what's going on: The tinyMCE plugin tries to loading before the main script. Can you do me a favor and add add_action( 'wp_enqueue_editor', [ $this, 'enqueue_assets' ] ); in https://github.com/mcguffin/the-paste/blob/master/include/ThePaste/Admin/Admin.php#L32 and try again?

— Reply to this email directly, view it on GitHub https://github.com/mcguffin/the-paste/issues/45#issuecomment-1736740194, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXNRHEJ72KHI2MFDRUAJ33X4O4SVANCNFSM6AAAAAA5IAHDUI . You are receiving this because you authored the thread.Message ID: @.***>

-- Best regards,

mcguffin commented 11 months ago

Thanks for the testing! 2.0.3 will be there soon.

Yes, the UI changes are fully intended. Feels more natural and acessible to just paste, saves some extra clicks and some code clutter too.
The filename image.png is only half-intentional. The plugin currently prefers filenames delivered by the browser (through ClipboardEvent.clipboardData.files to be specific), which is just image.png (or some localized string in Firefox) if you copy raw image data.
I personally would prefer the filename from the config here, as it would be more informative, but I couldn't figure out a rock solid way to distinguish between generic and ‘real’ filenames yet.
At this time the default filename feature only comes into effect, when you copy images from Google Docs.