TinyMCE: fix emoji parsing in IE. See #31242.

Built from https://develop.svn.wordpress.org/trunk@31761


git-svn-id: http://core.svn.wordpress.org/trunk@31742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-12 23:00:27 +00:00
parent b2dbe2080f
commit b20119d92f
4 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,7 @@
( function( tinymce, wp ) {
tinymce.PluginManager.add( 'wpemoji', function( editor, url ) {
var typing;
var typing
isMacWebKit = tinymce.Env.mac && tinymce.Env.webkit;
if ( ! wp.emoji.parseEmoji ) {
return;
@ -30,7 +31,10 @@
selection = editor.selection;
node = selection.getNode();
bookmark = selection.getBookmark();
if ( isMacWebKit ) {
bookmark = selection.getBookmark();
}
wp.emoji.parse( node );
@ -44,7 +48,15 @@
}
} );
selection.moveToBookmark( bookmark );
// In IE all content in the editor is left selected aftrer wp.emoji.parse()...
// Collapse the selection to the beginning.
if ( tinymce.Env.ie && node && node.nodeName === 'BODY' ) {
selection.collapse( true );
}
if ( isMacWebKit ) {
selection.moveToBookmark( bookmark );
}
} );
editor.on( 'postprocess', function( event ) {

View File

@ -1 +1 @@
!function(a,b){a.PluginManager.add("wpemoji",function(c,d){var e;b.emoji.parseEmoji&&(c.on("init",function(){var a=c.dom.uniqueId(),b=c.dom.create("link",{id:a,rel:"stylesheet",href:d+"/css/editor.css"});c.getDoc().getElementsByTagName("head")[0].appendChild(b)}),c.on("keydown keyup",function(a){e="keydown"===a.type}),c.on("input setcontent",function(d){var f,g,h,i;e&&"input"===d.type||(f=c.selection,g=f.getNode(),h=f.getBookmark(),b.emoji.parse(g),i=c.dom.select("img.emoji",g),a.each(i,function(a){a.getAttribute("data-wp-emoji")||(a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji",a.alt))}),f.moveToBookmark(h))}),c.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g,function(a,b){return b}))}),c.on("resolvename",function(a){"IMG"===a.target.nodeName&&c.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp);
!function(a,b){a.PluginManager.add("wpemoji",function(c,d){var e;isMacWebKit=a.Env.mac&&a.Env.webkit,b.emoji.parseEmoji&&(c.on("init",function(){var a=c.dom.uniqueId(),b=c.dom.create("link",{id:a,rel:"stylesheet",href:d+"/css/editor.css"});c.getDoc().getElementsByTagName("head")[0].appendChild(b)}),c.on("keydown keyup",function(a){e="keydown"===a.type}),c.on("input setcontent",function(d){var f,g,h,i;e&&"input"===d.type||(f=c.selection,g=f.getNode(),isMacWebKit&&(h=f.getBookmark()),b.emoji.parse(g),i=c.dom.select("img.emoji",g),a.each(i,function(a){a.getAttribute("data-wp-emoji")||(a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji",a.alt))}),a.Env.ie&&g&&"BODY"===g.nodeName&&f.collapse(!0),isMacWebKit&&f.moveToBookmark(h))}),c.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g,function(a,b){return b}))}),c.on("resolvename",function(a){"IMG"===a.target.nodeName&&c.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp);

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta1-31760';
$wp_version = '4.2-beta1-31761';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.