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