/*! * froala_editor v4.3.1 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms/ * Copyright 2014-2024 Froala Labs */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(e.FroalaEditor)}(this,function(E){"use strict";E=E&&E.hasOwnProperty("default")?E["default"]:E,Object.assign(E.DEFAULTS,{wordCounterMax:-1,wordCounterCount:!0}),E.PLUGINS.wordCounter=function(C){var r,t=C.$;function f(){var e=C.el.innerText.toString();e=(e=(e=(e=(e=(e=(e=(e=e.replace(/(^\s*)|(\s*$)/gi," ")).replace(/\u00a0/g," ")).replace(/[ ]{2,}/gi," ")).replace(/\n /,"\n")).replace(/[\u200A\u200C-\u200D\uFEFF\u202F\u2000-\u2009\u205F\u3000\u1680\u00A0\u0020]/g," ")).replace(/[\u200B]/g,"")).replace(/\t+/g," ")).split(" ").join("\n");var t=C.$el.find(".fr-pagebreak"),r=e.split(/\r?\n/),n=0;return r.forEach(function(e){0<(e=e.replace(/\s/g,"")).length&&n++}),n-2*t.length}function e(e){var t=!1;if(C.opts.wordCounterMax<0)return!0;if(f()C.opts.wordCounterMax&&(C.keys.isCharacter(r)||r===E.KEYCODE.ENTER)&&(t=!0),!(!C.keys.ctrlKey(e)&&t||r===E.KEYCODE.IME)||(e.preventDefault(),e.stopPropagation(),C.events.trigger("wordCounter.exceeded"),!1)}function n(){if(C.opts.wordCounterCount){var e=f()+(0").html(e).text().split(" ").length+f()<=C.opts.wordCounterMax?e:(C.events.trigger("wordCounter.exceeded"),"")}return{_init:function a(){return!!C.$wp&&!!C.opts.wordCounterCount&&((r=t(document.createElement("span")).attr("class","fr-counter fr-wCounter")).css("bottom",C.$wp.css("border-bottom-width")),C.$second_tb?C.$second_tb.append(r):C.$wp.append(r),C.events.on("keydown",e,!0),C.events.on("paste.afterCleanup",o),C.events.on("keyup contentChanged input",function(){C.events.trigger("wordCounter.update")}),C.events.on("wordCounter.update",n),C.events.trigger("wordCounter.update"),void C.events.on("destroy",function(){t(C.o_win).off("resize.char".concat(C.id)),r.removeData().remove(),r=null}))},wordCount:f}}});