/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.0.3 (2019-03-19) */ !function(){"use strict";var e,n,t,r,o,u=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),c=function(){return(c=Object.assign||function(e){for(var n,t=1,r=arguments.length;tu.length-1&&0!==i||s===E&&f===E||(a=u[i+2],s===E&&(f===R||f===x||f===k)&&a===E||(c=u[i-1],(s===R||s===x||f===k)&&f===E&&c===E||!(s!==b&&s!==E||f!==b&&f!==E)||(s===S||s===x)&&f===b&&c===b||s===b&&(f===S||f===x)&&a===b||s===N||s===j||c===N||c===j||f===N||f===j||s===O&&f===A||s!==C&&s!==O&&s!==A&&f!==C&&f!==O&&f!==A&&(s===T&&f===T||f===W&&(s===E||s===b||s===T||s===W)||s===W&&(f===E||f===b||f===T)||s===k))))){var d=n[g];if((r.includeWhitespace||!J.test(d))&&(r.includePunctuation||!K.test(d))){var h=g-p.length+1,y=g+1,w=n.slice(h,y).join("");if("http"===(o=w)||"https"===o){var v=L(n,g),m=e.slice(y,v);Array.prototype.push.apply(p,m),g=v}l.push(p)}p=[]}return l}(r,o,H(o),t)},V=function(e,n){for(var t,r=n.getBlockElements(),o=n.getShortEndedElements(),u=n.getWhiteSpaceElements(),i="",c=new a(e,e);e=c.next();)3===e.nodeType?i+=e.data:0!==i.length&&(r[(t=e).nodeName]||o[t.nodeName]||u[t.nodeName])&&(i+=" ");return i},X=function(e){return{words:Q(e.split(""),M).length,characters:e.length,charactersNoSpace:e.replace(/\s/g,"").length}},Y=function(e){return X((n=e).removed?"":V(n.getBody(),n.schema));var n},ee=tinymce.util.Tools.resolve("tinymce.util.Delay"),ne=function(e){var n,t=Y(e);n=t,e.fire("wordCountUpdate",{wordCount:n})},te=function(e){var n,t,r=Y(e),o=(t=V((n=e).selection.getRng().cloneContents(),n.schema),n.selection.isCollapsed()?X(""):X(t));e.windowManager.open({title:"Word Count",body:{type:"panel",items:[{type:"table",header:["Count","Document","Selection"],cells:[["Words",String(r.words),String(o.words)],["Characters (no spaces)",String(r.charactersNoSpace),String(o.charactersNoSpace)],["Characters",String(r.characters),String(o.characters)]]}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}]})};u.add("wordcount",function(e){var n,t,r,o;return(n=e).ui.registry.addButton("wordcount",{tooltip:"Word count",icon:"character-count",onAction:function(){return te(n)}}),n.ui.registry.addMenuItem("wordcount",{text:"Word count",icon:"character-count",onAction:function(){return te(n)}}),t=e,r=ee.debounce(function(){return ne(t)},300),t.on("init",function(){ne(t),ee.setEditorTimeout(t,function(){t.on("setcontent beforeaddundo undo redo keyup",r)},0)}),o=e,{getCount:function(){return Y(o).words}}}),function re(){}}();