Editor: word count: count astrals as one character
This makes sure an emoji, for example, is counted as one character. See #30966. Built from https://develop.svn.wordpress.org/trunk@33320 git-svn-id: http://core.svn.wordpress.org/trunk@33292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0729c70e03
commit
e9b6d25bcd
@ -57,6 +57,7 @@
|
|||||||
'\u2E00-\u2E7F',
|
'\u2E00-\u2E7F',
|
||||||
']'
|
']'
|
||||||
].join( '' ), 'g' ),
|
].join( '' ), 'g' ),
|
||||||
|
astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
||||||
wordsRegExp: /\S\s+/g,
|
wordsRegExp: /\S\s+/g,
|
||||||
charactersRegExp: /\S/g,
|
charactersRegExp: /\S/g,
|
||||||
allRegExp: /[^\f\n\r\t\v\u00ad\u2028\u2029]/g,
|
allRegExp: /[^\f\n\r\t\v\u00ad\u2028\u2029]/g,
|
||||||
@ -82,6 +83,8 @@
|
|||||||
if ( type === 'words' ) {
|
if ( type === 'words' ) {
|
||||||
text = text.replace( this.settings.connectorRegExp, ' ' );
|
text = text.replace( this.settings.connectorRegExp, ' ' );
|
||||||
text = text.replace( this.settings.removeRegExp, '' );
|
text = text.replace( this.settings.removeRegExp, '' );
|
||||||
|
} else {
|
||||||
|
text = text.replace( this.settings.astralRegExp, 'a' );
|
||||||
}
|
}
|
||||||
|
|
||||||
text = text.match( this.settings[ type + 'RegExp' ] );
|
text = text.match( this.settings[ type + 'RegExp' ] );
|
||||||
|
2
wp-admin/js/word-count.min.js
vendored
2
wp-admin/js/word-count.min.js
vendored
@ -1 +1 @@
|
|||||||
!function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","gi"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,spaceRegExp:/ | /gi,connectorRegExp:/--|\u2014/gi,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),wordsRegExp:/\S\s+/g,charactersRegExp:/\S/g,allRegExp:/[^\f\n\r\t\v\u00ad\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type||"words",a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b&&(a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}();
|
!function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","gi"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,spaceRegExp:/ | /gi,connectorRegExp:/--|\u2014/gi,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),astralRegExp:/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,wordsRegExp:/\S\s+/g,charactersRegExp:/\S/g,allRegExp:/[^\f\n\r\t\v\u00ad\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type||"words",a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b?(a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")):a=a.replace(this.settings.astralRegExp,"a"),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}();
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-beta3-33318';
|
$wp_version = '4.3-beta3-33320';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
Block a user