TinyMCE: fix selecting an image on touch in iOS Safari for TinyMCE 4.4.1.
Fixes #37427. git-svn-id: https://develop.svn.wordpress.org/trunk@38156 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
52ea1c53ac
commit
a08e89ed97
@ -79,24 +79,27 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
function isNonEditable( node ) {
|
||||||
|
var parent = editor.$( node ).parents( '[contenteditable]' );
|
||||||
|
return parent && parent.attr( 'contenteditable' ) === 'false';
|
||||||
|
}
|
||||||
|
|
||||||
// Safari on iOS fails to select images in contentEditoble mode on touch.
|
// Safari on iOS fails to select images in contentEditoble mode on touch.
|
||||||
// Select them again.
|
// Select them again.
|
||||||
if ( iOS ) {
|
if ( iOS ) {
|
||||||
editor.on( 'init', function() {
|
editor.on( 'init', function() {
|
||||||
editor.on( 'touchstart', function( event ) {
|
editor.on( 'touchstart', function( event ) {
|
||||||
if ( event.target.nodeName === 'IMG' ) {
|
if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
|
||||||
touchOnImage = true;
|
touchOnImage = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.dom.bind( editor.getDoc(), 'touchmove', function( event ) {
|
editor.dom.bind( editor.getDoc(), 'touchmove', function() {
|
||||||
if ( event.target.nodeName === 'IMG' ) {
|
touchOnImage = false;
|
||||||
touchOnImage = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.on( 'touchend', function( event ) {
|
editor.on( 'touchend', function( event ) {
|
||||||
if ( touchOnImage && event.target.nodeName === 'IMG' ) {
|
if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
|
||||||
var node = event.target;
|
var node = event.target;
|
||||||
|
|
||||||
touchOnImage = false;
|
touchOnImage = false;
|
||||||
@ -104,7 +107,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
window.setTimeout( function() {
|
window.setTimeout( function() {
|
||||||
editor.selection.select( node );
|
editor.selection.select( node );
|
||||||
editor.nodeChanged();
|
editor.nodeChanged();
|
||||||
}, 200 );
|
}, 100 );
|
||||||
} else if ( toolbar ) {
|
} else if ( toolbar ) {
|
||||||
toolbar.hide();
|
toolbar.hide();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user