diff --git a/wp-admin/js/word-count.js b/wp-admin/js/word-count.js index 40c2934b9e..0740bb6ef1 100644 --- a/wp-admin/js/word-count.js +++ b/wp-admin/js/word-count.js @@ -14,7 +14,42 @@ WordCounter.prototype.settings = { HTMLRegExp: /<\/?[a-z][^>]*?>/gi, spaceRegExp: / | /gi, - removeRegExp: /[0-9.(),;:!?%#$¿'"_+=\\\/-]+/g, + connectorRegExp: /--|\u2014/gi, + removeRegExp: new RegExp( [ + '[', + // Basic Latin (extract) + '\u0021-\u0040\u005B-\u0060\u007B-\u007E', + // Latin-1 Supplement (extract) + '\u0080-\u00BF\u00D7\u00F7', + // General Punctuation + // Superscripts and Subscripts + // Currency Symbols + // Combining Diacritical Marks for Symbols + // Letterlike Symbols + // Number Forms + // Arrows + // Mathematical Operators + // Miscellaneous Technical + // Control Pictures + // Optical Character Recognition + // Enclosed Alphanumerics + // Box Drawing + // Block Elements + // Geometric Shapes + // Miscellaneous Symbols + // Dingbats + // Miscellaneous Mathematical Symbols-A + // Supplemental Arrows-A + // Braille Patterns + // Supplemental Arrows-B + // Miscellaneous Mathematical Symbols-B + // Supplemental Mathematical Operators + // Miscellaneous Symbols and Arrows + '\u2000-\u2BFF', + // Supplemental Punctuation + '\u2E00-\u2E7F', + ']' + ].join( '' ), 'g' ), wordsRegExp: /\S\s+/g, charactersRegExp: /\S/g, allRegExp: /[^\f\n\r\t\v\u00ad\u2028\u2029]/g, @@ -31,7 +66,11 @@ text = text.replace( this.settings.HTMLRegExp, '\n' ); text = text.replace( this.settings.spaceRegExp, ' ' ); - text = text.replace( this.settings.removeRegExp, '' ); + + if ( type === 'words' ) { + text = text.replace( this.settings.connectorRegExp, ' ' ); + text = text.replace( this.settings.removeRegExp, '' ); + } text = text.match( this.settings[ type + 'RegExp' ] ); diff --git a/wp-admin/js/word-count.min.js b/wp-admin/js/word-count.min.js index 2bb6265369..8b1472b528 100644 --- a/wp-admin/js/word-count.min.js +++ b/wp-admin/js/word-count.min.js @@ -1 +1 @@ -!function(){function a(a){var b;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b])}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,spaceRegExp:/ | /gi,removeRegExp:/[0-9.(),;:!?%#$¿'"_+=\\\/-]+/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"),a=a.replace(this.settings.spaceRegExp," "),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}(); \ No newline at end of file +!function(){function a(a){var b;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b])}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"),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}(); \ No newline at end of file diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index 4171858826..e81473ec6c 100644 --- a/wp-includes/js/mce-view.min.js +++ b/wp-includes/js/mce-view.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a,b,c){"use strict";var d={},e={};b.mce=b.mce||{},b.mce.views={register:function(a,c){d[a]=b.mce.View.extend(_.extend(c,{type:a}))},unregister:function(a){delete d[a]},get:function(a){return d[a]},unbind:function(){_.each(e,function(a){a.unbind()})},setMarkers:function(a){var b,c,e=[{content:a}],f=this;return _.each(d,function(a,d){c=e.slice(),e=[],_.each(c,function(c){var g,h,i=c.content;if(c.processed)return void e.push(c);for(;i&&(g=a.prototype.match(i));)g.index&&e.push({content:i.substring(0,g.index)}),b=f.createInstance(d,g.content,g.options),h=b.loader?".":b.text,e.push({content:'
'+h+"
",processed:!0}),i=i.slice(g.index+g.content.length);i&&e.push({content:i})})}),a=_.pluck(e,"content").join(""),a.replace(/\s*
")},createInstance:function(a,b,c){var d,f,g=this.get(a);return b=tinymce.DOM.decode(b),(f=this.getInstance(b))?f:(d=encodeURIComponent(b),c=_.extend(c||{},{text:b,encodedText:d}),e[d]=new g(c))},getInstance:function(a){return"string"==typeof a?e[encodeURIComponent(a)]:e[c(a).attr("data-wpview-text")]},getText:function(a){return decodeURIComponent(c(a).attr("data-wpview-text")||"")},render:function(a){_.each(e,function(b){b.render(a)})},update:function(a,b,c){var d=this.getInstance(c);d&&d.update(a,b,c)},edit:function(a,b){var c=this.getInstance(b);c&&c.edit&&c.edit(c.text,function(d){c.update(d,a,b)})},remove:function(a,b){var c=this.getInstance(b);c&&c.remove(a,b)}},b.mce.View=function(a){_.extend(this,a),this.initialize()},b.mce.View.extend=Backbone.View.extend,_.extend(b.mce.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(){return this.content},render:function(a,b){null!=a&&(this.content=a),a=this.getContent(),(this.loader||a)&&(b&&this.unbind(),this.replaceMarkers(),a?this.setContent(a,function(a,b,d){c(b).data("rendered",!0),this.bindNode.call(this,a,b,d)},b?null:!1):this.setLoader())},bindNode:function(){},unbindNode:function(){},unbind:function(){this.getNodes(function(a,b,d){this.unbindNode.call(this,a,b,d),c(b).trigger("wp-mce-view-unbind")},!0)},getEditors:function(a){_.each(tinymce.editors,function(b){b.plugins.wpview&&a.call(this,b)},this)},getNodes:function(a,b){this.getEditors(function(d){var e=this;c(d.getBody()).find('[data-wpview-text="'+e.encodedText+'"]').filter(function(){var a;return null==b?!0:(a=c(this).data("rendered")===!0,b?a:!a)}).each(function(){a.call(e,d,this,c(this).find(".wpview-content").get(0))})})},getMarkers:function(a){this.getEditors(function(b){var d=this;c(b.getBody()).find('[data-wpview-marker="'+this.encodedText+'"]').each(function(){a.call(d,b,this)})})},replaceMarkers:function(){this.getMarkers(function(a,b){return this.loader||c(b).text()===this.text?void a.dom.replace(a.dom.createFragment('