/** * 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.12 (2019-07-18) */ !function(){"use strict";var t,n,e,r,o,u=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(t){return function(){return t}},c=function(t){return t},a=i(!1),f=i(!0),s=function(){return(s=Object.assign||function(t){for(var n,e=1,r=arguments.length;eu.length-1&&0!==i||f===S&&s===S||(a=u[i+2],f===S&&(s===W||s===x||s===F)&&a===S||(c=u[i-1],(f===W||f===x||s===F)&&s===S&&c===S||!(f!==O&&f!==S||s!==O&&s!==S)||(f===R||f===x)&&s===O&&c===O||f===O&&(s===R||s===x)&&a===O||f===T||f===k||c===T||c===k||s===T||s===k||f===A&&s===j||f!==D&&f!==A&&f!==j&&s!==D&&s!==A&&s!==j&&(f===P&&s===P||s===B&&(f===S||f===O||f===P||f===B)||f===B&&(s===S||s===O||s===P)||f===F))))){var d=n[p];if((r.includeWhitespace||!J.test(d))&&(r.includePunctuation||!K.test(d))){var h=p-g.length+1,y=p+1,C=n.slice(h,y).join("");if("http"===(o=C)||"https"===o){var v=L(n,p),w=t.slice(y,v);Array.prototype.push.apply(g,w),p=v}l.push(g)}g=[]}return l}(r,o,H(o),e)},V=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),X=function(t,n){for(var e,r=n.getBlockElements(),o=n.getShortEndedElements(),u=[],i="",c=new V(t,t);t=c.next();)3===t.nodeType?i+=t.data:(r[(e=t).nodeName]||o[e.nodeName])&&i.length&&(u.push(i),i="");return i.length&&u.push(i),u},Y=function(t){return t.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"_").length},tt=function(t,n){var e=X(t,n).join("\n");return Q(e.split(""),c).length},nt=function(t,n){var e=X(t,n).join("");return Y(e)},et=function(t,n){var e=X(t,n).join("").replace(/\s/g,"");return Y(e)},rt=function(t,n){return function(){return n(t.getBody(),t.schema)}},ot=function(t,n){return function(){return n(t.selection.getRng().cloneContents(),t.schema)}},ut=function(t){return rt(t,tt)},it=tinymce.util.Tools.resolve("tinymce.util.Delay"),ct=function(t,n){var e;e=n,t.fire("wordCountUpdate",{wordCount:{words:e.body.getWordCount(),characters:e.body.getCharacterCount(),charactersWithoutSpaces:e.body.getCharacterCountWithoutSpaces()}})},at=function(t,n){t.windowManager.open({title:"Word Count",body:{type:"panel",items:[{type:"table",header:["Count","Document","Selection"],cells:[["Words",String(n.body.getWordCount()),String(n.selection.getWordCount())],["Characters (no spaces)",String(n.body.getCharacterCountWithoutSpaces()),String(n.selection.getCharacterCountWithoutSpaces())],["Characters",String(n.body.getCharacterCount()),String(n.selection.getCharacterCount())]]}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}]})};!function ft(){u.add("wordcount",function(t){var n,e,r,o,u,i,c={body:{getWordCount:ut(n=t),getCharacterCount:rt(n,nt),getCharacterCountWithoutSpaces:rt(n,et)},selection:{getWordCount:ot(n,tt),getCharacterCount:ot(n,nt),getCharacterCountWithoutSpaces:ot(n,et)},getCount:ut(n)};return r=c,(e=t).ui.registry.addButton("wordcount",{tooltip:"Word count",icon:"character-count",onAction:function(){return at(e,r)}}),e.ui.registry.addMenuItem("wordcount",{text:"Word count",icon:"character-count",onAction:function(){return at(e,r)}}),o=t,u=c,i=it.debounce(function(){return ct(o,u)},300),o.on("init",function(){ct(o,u),it.setEditorTimeout(o,function(){o.on("SetContent BeforeAddUndo Undo Redo keyup",i)},0)}),c})}()}();