Files

1 line
857 B
JavaScript
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
tinymce.PluginManager.add("wordcount",function(f){function d(){f.theme.panel.find("#wordcount").text(["Words: {0}",b.getCount()])}var g,c,b=this;g=f.getParam("wordcount_countregex",/[\w\u2019\x27\-]+/g),c=f.getParam("wordcount_cleanregex",/[0-9.(),;:!?%#$?\x27\x22_+=\\\/\-]*/g),f.on("init",function(){var a=f.theme.panel&&f.theme.panel.find("#statusbar")[0];a&&window.setTimeout(function(){a.insert({type:"label",name:"wordcount",text:["Words: {0}",b.getCount()],classes:"wordcount"},0),f.on("setcontent beforeaddundo",d),f.on("keyup",function(h){32==h.keyCode&&d()})},0)}),b.getCount=function(){var h=f.getContent({format:"raw"}),e=0;if(h){h=h.replace(/\.\.\./g," "),h=h.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," "),h=h.replace(/(\w+)(&.+?;)+(\w+)/,"$1$3").replace(/&.+?;/g," "),h=h.replace(c,"");var i=h.match(g);i&&(e=i.length)}return e}});