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
This commit is contained in:
parent
1285d1450b
commit
c46233940f
@ -12,9 +12,16 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
cursorInterval, lastKeyDownNode, setViewCursorTries, focus;
|
cursorInterval, lastKeyDownNode, setViewCursorTries, focus;
|
||||||
|
|
||||||
function getView( node ) {
|
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 ) {
|
while ( node && node.parentNode ) {
|
||||||
if ( node.className && (' ' + node.className + ' ').indexOf(' wpview-wrap ') !== -1 ) {
|
if ( node.className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1 ) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +630,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
}, 500 );
|
}, 500 );
|
||||||
// If the cursor lands anywhere else in the view, set the cursor before it.
|
// 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.)
|
// 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();
|
deselect();
|
||||||
setViewCursorTries++;
|
setViewCursorTries++;
|
||||||
setViewCursor( true, view );
|
setViewCursor( true, view );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user