From 67032cf170fd82ebeb60873e01a852d473d77a56 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 25 Jul 2014 00:55:33 +0000 Subject: [PATCH] TinyMCE wpView: - Fix opening the media modal on clicking Edit in Firefox. - Fix range errors when restoring the selection bookmark in IE11 after editing a view. See #28595. git-svn-id: https://develop.svn.wordpress.org/trunk@29298 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpview/plugin.js | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js index 2d5ce5c12e..f770ada825 100644 --- a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -115,7 +115,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { dom = editor.dom; // Bail if node is already selected. - if ( viewNode === selected ) { + if ( ! viewNode || viewNode === selected ) { return; } @@ -295,34 +295,24 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { if ( view ) { event.stopPropagation(); - // Hack to try and keep the block resize handles from appearing. They will show on mousedown and then be removed on mouseup. - if ( Env.ie <= 10 ) { - deselect(); + if ( event.type === 'mousedown' && ! event.metaKey && ! event.ctrlKey ) { + if ( editor.dom.hasClass( event.target, 'edit' ) ) { + wp.mce.views.edit( view ); + editor.focus(); + return false; + } else if ( editor.dom.hasClass( event.target, 'remove' ) ) { + removeView( view ); + return false; + } } select( view ); - if ( event.type === 'click' && ! event.metaKey && ! event.ctrlKey ) { - if ( editor.dom.hasClass( event.target, 'edit' ) ) { - wp.mce.views.edit( view ); - } else if ( editor.dom.hasClass( event.target, 'remove' ) ) { - removeView( view ); - } - } - // Returning false stops the ugly bars from appearing in IE11 and stops the view being selected as a range in FF. // Unfortunately, it also inhibits the dragging of views to a new location. return false; } else { - // Fix issue with deselecting a view in IE8. Without this hack, clicking content above the view wouldn't actually deselect it - // and the caret wouldn't be placed at the mouse location - if ( Env.ie && Env.ie <= 8 ) { - deselectEventType = 'mouseup'; - } else { - deselectEventType = 'mousedown'; - } - - if ( event.type === deselectEventType ) { + if ( event.type === 'mousedown' ) { deselect(); } }