From c46233940ff87dfdd4a445091a65cb5920ff3223 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 12 Jul 2014 22:50:19 +0000 Subject: [PATCH] TinyMCE wpView: fix selecting views on click, part props avryl, see #28595 git-svn-id: https://develop.svn.wordpress.org/trunk@29126 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wpview/plugin.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js index 0b10ff296a..0f21cfea81 100644 --- a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -12,9 +12,16 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { cursorInterval, lastKeyDownNode, setViewCursorTries, focus; function getView( node ) { - // Doing this directly is about 40% faster + return getParent( node, 'wpview-wrap' ); + } + + /** + * Returns the node or a parent of the node that has the passed className. + * Doing this directly is about 40% faster + */ + function getParent( node, className ) { while ( node && node.parentNode ) { - if ( node.className && (' ' + node.className + ' ').indexOf(' wpview-wrap ') !== -1 ) { + if ( node.className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1 ) { return node; } @@ -623,7 +630,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { }, 500 ); // If the cursor lands anywhere else in the view, set the cursor before it. // Only try this once to prevent a loop. (You never know.) - } else if ( className !== 'wpview-clipboard' && ! setViewCursorTries ) { + } else if ( ! getParent( event.element, 'wpview-body' ) && ! setViewCursorTries ) { deselect(); setViewCursorTries++; setViewCursor( true, view );