WordPress.org

Support

Support » Plugins and Hacks » Subscribe2 » [Resolved] TinyMCE V4 Plugin Conflict

[Resolved] TinyMCE V4 Plugin Conflict

  • 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/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] TinyMCE V4 Plugin Conflict’ is closed to new replies.
Skip to toolbar