TinyMCE wpView: when clicking in the editor optimize the caret placement before or after a view. Props avryl, fixes #30938.

git-svn-id: https://develop.svn.wordpress.org/trunk@31143 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-01-11 20:41:36 +00:00
parent 5a29757b92
commit 43b2de66c6

View File

@ -162,7 +162,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
toolbar = editor.$( viewNode ).find( '.toolbar' ),
editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0],
editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0;
if ( toolbar.length && editor.iframeElement ) {
// 48 = 43 for the toolbar + 5 buffer
delta = viewNode.getBoundingClientRect().top + editor.iframeElement.getBoundingClientRect().top - editorToolbarBottom - 48;
@ -264,10 +264,14 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
} else if ( y > lastRect.bottom && ( view = getView( last ) ) ) {
setViewCursor( false, view );
event.preventDefault();
} else {
} else if ( x < bodyRect.left || x > bodyRect.right ) {
tinymce.each( editor.dom.select( '.wpview-wrap' ), function( view ) {
var rect = view.getBoundingClientRect();
if ( y < rect.top ) {
return false;
}
if ( y >= rect.top && y <= rect.bottom ) {
if ( x < bodyRect.left ) {
setViewCursor( true, view );
@ -276,7 +280,8 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
setViewCursor( false, view );
event.preventDefault();
}
return;
return false;
}
});
}