froala-editor
Version:
The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.
7 lines (6 loc) • 2.18 kB
JavaScript
/*!
* froala_editor v5.0.1 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2026 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(("undefined"!=typeof globalThis?globalThis:e||self).FroalaEditor)}(this,function(e){"use strict";Object.assign(e.DEFAULTS,{saveInterval:1e4,saveURL:null,saveParams:{},saveParam:"body",saveMethod:"POST"}),e.PLUGINS.save=function(i){var r=i.$,n=null,f=null,t=!1,l=1,c=2,s={};function v(e,t){i.events.trigger("save.error",[{code:e,message:s[e]},t])}function a(e){var n=e=void 0===e?i.html.get():e,t=i.events.trigger("save.before",[e]);if(!1===t)return!1;if("string"==typeof t&&(e=t),i.opts.saveURL){var s,a,o={};for(s in i.opts.saveParams)i.opts.saveParams.hasOwnProperty(s)&&(a=i.opts.saveParams[s],o[s]="function"==typeof a?a.call(this):a);t={};t[i.opts.saveParam]=e,r(this).ajax({method:i.opts.saveMethod,url:i.opts.saveURL,data:Object.assign(t,o),crossDomain:i.opts.requestWithCORS,withCredentials:i.opts.requestWithCredentials,headers:i.opts.requestHeaders,done:function(e,t,s){f=n,i.events.trigger("save.after",[e])},fail:function(e){v(c,e.response||e.responseText)}})}else v(l)}function o(){clearTimeout(n),n=setTimeout(function(){var e=i.html.get();f==e&&!t||(t=!1,a(f=e))},0)}return s[l]="Missing saveURL option.",s[c]="Something went wrong during save.",{_init:function(){if(i.opts.letteringClass)for(var e=i.opts.letteringClass,t=i.$el.find(".".concat(e)).length,s=0;s<t;s++)i.$el.find(".".concat(e))[s].innerHTML=i.$el.find(".".concat(e))[s].innerText.replace(/([\w'-]+|[?.",])/g,"<span class = 'fr-word-select'>$1</span>");i.opts.saveInterval&&(f=i.html.get(),i.events.on("contentChanged",function(){setTimeout(o,i.opts.saveInterval)}),i.events.on("keydown destroy",function(){clearTimeout(n)}))},save:a,reset:function(){o(),t=!1},force:function(){t=!0}}},e.DefineIcon("save",{NAME:"floppy-o",FA5NAME:"save"}),e.RegisterCommand("save",{title:"Save",undo:!1,focus:!1,refreshAfterCallback:!1,callback:function(){this.save.save()},plugin:"save"})});