From 29cca14491fe27d3655ad8922e6bb6a26510bf60 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 12 Mar 2015 22:59:41 +0000 Subject: [PATCH] TinyMCE: fix emoji parsing in IE. See #31242. git-svn-id: https://develop.svn.wordpress.org/trunk@31761 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpemoji/plugin.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js b/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js index 82741b676d..af65ea48bd 100755 --- a/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js @@ -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 ) {