WordPress.org

Make WordPress Core

Changeset 33320


Ignore:
Timestamp:
07/18/2015 11:41:25 AM (5 years ago)
Author:
iseulde
Message:

Editor: word count: count astrals as one character

This makes sure an emoji, for example, is counted as one character.

See #30966.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/word-count.js

    r33299 r33320  
    5858            ']'
    5959        ].join( '' ), 'g' ),
     60        astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
    6061        wordsRegExp: /\S\s+/g,
    6162        charactersRegExp: /\S/g,
     
    8384                text = text.replace( this.settings.connectorRegExp, ' ' );
    8485                text = text.replace( this.settings.removeRegExp, '' );
     86            } else {
     87                text = text.replace( this.settings.astralRegExp, 'a' );
    8588            }
    8689
  • trunk/tests/qunit/wp-admin/js/word-count.js

    r33299 r33320  
    5252                characters: 11,
    5353                all: 12
     54            },
     55            {
     56                message: 'Astrals.',
     57                string: '\uD83D\uDCA9',
     58                words: 1,
     59                characters: 1,
     60                all: 1
    5461            }
    5562        ], function( test ) {
Note: See TracChangeset for help on using the changeset viewer.