Make WordPress Core

Changeset 31946


Ignore:
Timestamp:
03/31/2015 11:34:23 PM (12 years ago)
Author:
azaozz
Message:

TinyMCE emoji: fix caret position after replacing emoji in Chrome on Windows 8.
See #31627.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js

    r31923 r31946  
    3131                }
    3232
     33                // Test if the node text contains emoji char(s) and replace.
     34                function parseNode( node ) {
     35                        var selection, bookmark;
     36
     37                        if ( node && twemoji.test( node.textContent || node.innerText ) ) {
     38                                if ( env.webkit ) {
     39                                        selection = editor.selection;
     40                                        bookmark = selection.getBookmark();
     41                                }
     42
     43                                replaceEmoji( node );
     44
     45                                if ( env.webkit ) {
     46                                        selection.moveToBookmark( bookmark );
     47                                }
     48                        }
     49                }
     50
    3351                if ( isWin8 ) {
    3452                        // Windows 8+ emoji can be "typed" with the onscreen keyboard.
    … …  
    3654                        // Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
    3755                        editor.on( 'keyup', function( event ) {
    38                                 var node;
    39 
    4056                                if ( event.keyCode === 231 ) {
    41                                         node = editor.selection.getNode();
    42 
    43                                         if ( twemoji.test( node.textContent || node.innerText ) ) {
    44                                                 replaceEmoji( node );
    45                                         }
     57                                        parseNode( editor.selection.getNode() );
    4658                                }
    4759                        } );
    … …  
    5971                                }
    6072
    61                                 var bookmark,
    62                                         selection = editor.selection,
    63                                         node = selection.getNode();
    64 
    65                                 if ( twemoji.test( node.textContent || node.innerText ) ) {
    66                                         if ( env.webkit ) {
    67                                                 bookmark = selection.getBookmark();
    68                                         }
    69 
    70                                         replaceEmoji( node );
    71 
    72                                         if ( env.webkit ) {
    73                                                 selection.moveToBookmark( bookmark );
    74                                         }
    75                                 }
     73                                parseNode( editor.selection.getNode() );
    7674                        });
    7775                }
Note: See TracChangeset for help on using the changeset viewer.