app/assets/javascripts/plugins/word_counter.min.js in wysiwyg-rails-4.3.0 vs app/assets/javascripts/plugins/word_counter.min.js in wysiwyg-rails-4.3.1

- old
+ new

@@ -1,6 +1,6 @@ /*! - * froala_editor v4.3.0 (https://www.froala.com/wysiwyg-editor) + * 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)return!0;var r=e.which,n=C.selection.get(),o=n.focusOffset,a=n.focusNode.textContent,u=(a=a.replace(/\u00a0/g," ")).toUpperCase().charCodeAt(o-1),i=a.toUpperCase().charCodeAt(o);return n.focusNode.data||(u=i=NaN),!function s(e,t){if(C.keys.isCharacter(e)&&C.keys.isCharacter(t)&&e!=E.KEYCODE.SPACE&&t!=E.KEYCODE.SPACE)return!0;return!1}(u,i)||r!==E.KEYCODE.ENTER&&r!==E.KEYCODE.SPACE||(t=!0),(function c(e,t){return e===E.KEYCODE.SPACE&&t===E.KEYCODE.SPACE}(u,i)||function d(e,t){if(isNaN(e)&&t===E.KEYCODE.SPACE||e===E.KEYCODE.SPACE&&isNaN(t))return!0;return!1}(u,i)||function p(e,t){if(isNaN(e)&&isNaN(t))return!0;return!1}(u,i))&&C.keys.isCharacter(r)&&r!=E.KEYCODE.SPACE&&(t=!0),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<C.opts.wordCounterMax?"/"+C.opts.wordCounterMax:"");r.text("".concat(C.language.translate("Words")," : ").concat(e)),C.opts.toolbarBottom&&r.css("margin-bottom",C.$tb.outerHeight(!0));var t=C.$wp.get(0).offsetWidth-C.$wp.get(0).clientWidth;0<=t&&("rtl"==C.opts.direction?r.css("margin-left",t):r.css("margin-right",t))}}function o(e){return C.opts.wordCounterMax<0?e:t("<div>").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}}}); \ No newline at end of file