TinyMCE emoji: fix caret position after replacing emoji in Chrome on Windows 8.
See #31627. Built from https://develop.svn.wordpress.org/trunk@31946 git-svn-id: http://core.svn.wordpress.org/trunk@31925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d775c933c7
commit
5fe7be9757
|
@ -30,19 +30,31 @@
|
||||||
tinymce.each( editor.dom.$( 'img._inserted-emoji', node ), setImgAttr );
|
tinymce.each( editor.dom.$( 'img._inserted-emoji', node ), setImgAttr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test if the node text contains emoji char(s) and replace.
|
||||||
|
function parseNode( node ) {
|
||||||
|
var selection, bookmark;
|
||||||
|
|
||||||
|
if ( node && twemoji.test( node.textContent || node.innerText ) ) {
|
||||||
|
if ( env.webkit ) {
|
||||||
|
selection = editor.selection;
|
||||||
|
bookmark = selection.getBookmark();
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceEmoji( node );
|
||||||
|
|
||||||
|
if ( env.webkit ) {
|
||||||
|
selection.moveToBookmark( bookmark );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( isWin8 ) {
|
if ( isWin8 ) {
|
||||||
// Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
// Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
||||||
// That triggers the normal keyboard events, but not the 'input' event.
|
// That triggers the normal keyboard events, but not the 'input' event.
|
||||||
// Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
// Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
||||||
editor.on( 'keyup', function( event ) {
|
editor.on( 'keyup', function( event ) {
|
||||||
var node;
|
|
||||||
|
|
||||||
if ( event.keyCode === 231 ) {
|
if ( event.keyCode === 231 ) {
|
||||||
node = editor.selection.getNode();
|
parseNode( editor.selection.getNode() );
|
||||||
|
|
||||||
if ( twemoji.test( node.textContent || node.innerText ) ) {
|
|
||||||
replaceEmoji( node );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} else if ( ! isWin ) {
|
} else if ( ! isWin ) {
|
||||||
|
@ -58,21 +70,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bookmark,
|
parseNode( editor.selection.getNode() );
|
||||||
selection = editor.selection,
|
|
||||||
node = selection.getNode();
|
|
||||||
|
|
||||||
if ( twemoji.test( node.textContent || node.innerText ) ) {
|
|
||||||
if ( env.webkit ) {
|
|
||||||
bookmark = selection.getBookmark();
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceEmoji( node );
|
|
||||||
|
|
||||||
if ( env.webkit ) {
|
|
||||||
selection.moveToBookmark( bookmark );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(a,b,c){a.PluginManager.add("wpemoji",function(d){function e(a){a.className="emoji",a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji",a.alt)}function f(c){b.emoji.parse(c,{className:"emoji _inserted-emoji"}),a.each(d.dom.$("img._inserted-emoji",c),e)}var g,h=a.Env,i=window.navigator.userAgent,j=i.indexOf("Windows")>-1,k=function(){var a=i.match(/Windows NT 6\.(\d)/);return a&&a[1]>1?!0:!1}();b&&b.emoji&&b.emoji.replaceEmoji&&(k?d.on("keyup",function(a){var b;231===a.keyCode&&(b=d.selection.getNode(),c.test(b.textContent||b.innerText)&&f(b))}):j||(d.on("keydown keyup",function(a){g="keydown"===a.type}),d.on("input",function(){if(!g){var a,b=d.selection,e=b.getNode();c.test(e.textContent||e.innerText)&&(h.webkit&&(a=b.getBookmark()),f(e),h.webkit&&b.moveToBookmark(a))}})),d.on("setcontent",function(a){var b=d.selection,e=b.getNode();c.test(e.textContent||e.innerText)&&(f(e),h.ie&&h.ie<9&&a.load&&e&&"BODY"===e.nodeName&&b.collapse(!0))}),d.on("PastePostProcess",function(b){c&&a.each(d.dom.$("img.emoji",b.node),function(a){a.alt&&c.test(a.alt)&&e(a)})}),d.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g,"$1"))}),d.on("resolvename",function(a){"IMG"===a.target.nodeName&&d.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp,window.twemoji);
|
!function(a,b,c){a.PluginManager.add("wpemoji",function(d){function e(a){a.className="emoji",a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji",a.alt)}function f(c){b.emoji.parse(c,{className:"emoji _inserted-emoji"}),a.each(d.dom.$("img._inserted-emoji",c),e)}function g(a){var b,e;a&&c.test(a.textContent||a.innerText)&&(i.webkit&&(b=d.selection,e=b.getBookmark()),f(a),i.webkit&&b.moveToBookmark(e))}var h,i=a.Env,j=window.navigator.userAgent,k=j.indexOf("Windows")>-1,l=function(){var a=j.match(/Windows NT 6\.(\d)/);return a&&a[1]>1?!0:!1}();b&&b.emoji&&b.emoji.replaceEmoji&&(l?d.on("keyup",function(a){231===a.keyCode&&g(d.selection.getNode())}):k||(d.on("keydown keyup",function(a){h="keydown"===a.type}),d.on("input",function(){h||g(d.selection.getNode())})),d.on("setcontent",function(a){var b=d.selection,e=b.getNode();c.test(e.textContent||e.innerText)&&(f(e),i.ie&&i.ie<9&&a.load&&e&&"BODY"===e.nodeName&&b.collapse(!0))}),d.on("PastePostProcess",function(b){c&&a.each(d.dom.$("img.emoji",b.node),function(a){a.alt&&c.test(a.alt)&&e(a)})}),d.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g,"$1"))}),d.on("resolvename",function(a){"IMG"===a.target.nodeName&&d.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp,window.twemoji);
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-beta3-31945';
|
$wp_version = '4.2-beta3-31946';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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