WordPress.org

Ready to get started?Download WordPress

Forums

Subscribe2
[resolved] TinyMCE V4 Plugin Conflict (4 posts)

  1. Greg Ross
    Member
    Posted 2 months ago #

    There is an issue with the TinyMCE V4 plugin in Subscribe2, it breaks several other plugins like TinyMCE Spell Check, JetPack Spell Checker and Shortcoder.

    The following code causes a JavaScript error:

    // allow selection of the image placeholder
    ed.on('click', function ( ed ) {
    	if ( ed.toElement.nodeName === 'IMG' && ed.toElement.className === cls ) {
    		ed.selection.select( ed );
    	}
    });

    This is because ed.toElement is undefined in the ed object in TinyMCE 4. As the code doesn't check that before trying to get nodeName, it fails.

    A simple check can resolve the issue:

    // allow selection of the image placeholder
    ed.on('click', function ( ed ) {
    	if ( typeof ed.toElement !== "undefined" ) {
    		if ( ed.toElement.nodeName === 'IMG' && ed.toElement.className === cls ) {
    			ed.selection.select( ed );
    		}
    	}
    });

    However the above code will never execute the ed.selection.select(ed) call as it will never be true in TinyMCE 4.

    It doesn't look like the code is required at all as everything works fine if you delete the entire ed.on() block.

    Fixing the code to use srcElement instead works better but ed.selection doesn't exist in TinyMCE 4 either so it then breaks when you actually select the S2 img.

    https://wordpress.org/plugins/subscribe2/

  2. mattyrob
    Member
    Plugin Contributor

    Posted 2 months ago #

    @Greg,

    Thanks for this, I haven't seen any errors but that code is pretty old and was simply migrated for the new version of TinyMCE. I'll get it double checked and pull it out if it's no longer needed.

  3. Greg Ross
    Member
    Posted 2 months ago #

    Thanks.

  4. mattyrob
    Member
    Plugin Contributor

    Posted 2 months ago #

    @Greg,

    I have reproduced the error now. I've tested and implemented your proposed fix - thanks for your excellent bug report.
    http://plugins.trac.wordpress.org/changeset/919578

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.