TinyMCE wpView: when clicking in the editor optimize the caret placement before or after a view. Props avryl, fixes #30938.
Built from https://develop.svn.wordpress.org/trunk@31143 git-svn-id: http://core.svn.wordpress.org/trunk@31124 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
49c0b22828
commit
d079899553
|
@ -162,7 +162,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
toolbar = editor.$( viewNode ).find( '.toolbar' ),
|
toolbar = editor.$( viewNode ).find( '.toolbar' ),
|
||||||
editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0],
|
editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0],
|
||||||
editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0;
|
editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0;
|
||||||
|
|
||||||
if ( toolbar.length && editor.iframeElement ) {
|
if ( toolbar.length && editor.iframeElement ) {
|
||||||
// 48 = 43 for the toolbar + 5 buffer
|
// 48 = 43 for the toolbar + 5 buffer
|
||||||
delta = viewNode.getBoundingClientRect().top + editor.iframeElement.getBoundingClientRect().top - editorToolbarBottom - 48;
|
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 ) ) ) {
|
} else if ( y > lastRect.bottom && ( view = getView( last ) ) ) {
|
||||||
setViewCursor( false, view );
|
setViewCursor( false, view );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else {
|
} else if ( x < bodyRect.left || x > bodyRect.right ) {
|
||||||
tinymce.each( editor.dom.select( '.wpview-wrap' ), function( view ) {
|
tinymce.each( editor.dom.select( '.wpview-wrap' ), function( view ) {
|
||||||
var rect = view.getBoundingClientRect();
|
var rect = view.getBoundingClientRect();
|
||||||
|
|
||||||
|
if ( y < rect.top ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( y >= rect.top && y <= rect.bottom ) {
|
if ( y >= rect.top && y <= rect.bottom ) {
|
||||||
if ( x < bodyRect.left ) {
|
if ( x < bodyRect.left ) {
|
||||||
setViewCursor( true, view );
|
setViewCursor( true, view );
|
||||||
|
@ -276,7 +280,8 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
setViewCursor( false, view );
|
setViewCursor( false, view );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31142';
|
$wp_version = '4.2-alpha-31143';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue