froala-editor
Version:
A beautiful 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) • 3.52 kB
JavaScript
/*!
* froala_editor v2.9.2 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2019 Froala Labs
*/
!function(s){"function"==typeof define&&define.amd?define(["jquery"],s):"object"==typeof module&&module.exports?module.exports=function(e,t){return t===undefined&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),s(t)}:s(window.jQuery)}(function(a){a.FE.DEFAULT_SCAYT_OPTIONS={enableOnTouchDevices:!1,disableOptionsStorage:["all"],localization:"en",extraModules:"ui",DefaultSelection:"American English",spellcheckLang:"en_US",contextMenuSections:"suggest|moresuggest",serviceProtocol:"https",servicePort:"80",serviceHost:"svc.webspellchecker.net",servicePath:"spellcheck/script/ssrv.cgi",contextMenuForMisspelledOnly:!0,scriptPath:"https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js"},a.extend(a.FE.DEFAULTS,{scaytAutoload:!1,scaytCustomerId:"1:tLBmI3-7rr3J1-GMEFA1-mIewo-hynTZ1-PV38I1-uEXCy2-Rn81L-gXuG4-NUNri4-5q9Q34-Jd",scaytOptions:{}}),a.FE.PLUGINS.spellChecker=function(s){var l;function e(e){if(l&&l.isDisabled){var t=!l.isDisabled();e.toggleClass("fr-active",t).attr("aria-pressed",t),s.$el.attr("spellcheck",s.opts.spellcheck&&!t)}}function t(e){l&&l.isDisabled&&!l.isDisabled()&&0<=["bold","italic","underline","strikeThrough","subscript","superscript","fontFamily","fontSize","html"].indexOf(e)&&l.removeMarkupInSelectionNode({removeInside:!0})}function n(e){l&&l.isDisabled&&!l.isDisabled()&&0<=["bold","italic","underline","strikeThrough","subscript","superscript","fontFamily","fontSize","html"].indexOf(e)&&l.reloadMarkup()}function o(e){l&&l.isDisabled&&!l.isDisabled()&&(e.which==a.FE.KEYCODE.ENTER&&setTimeout(l.reloadMarkup,0))}function r(e){if(e&&e.getAttribute&&e.getAttribute("data-scayt-word"))e.outerHTML=e.innerHTML;else if(e&&e.nodeType==Node.ELEMENT_NODE)for(var t=e.querySelectorAll("[data-scayt-word], [data-spelling-word]"),s=0;s<t.length;s++)t[s].outerHTML=t[s].innerHTML}function i(){s.events.on("commands.before",t),s.events.on("commands.after",n),s.events.on("keydown",o,!0),s.events.on("html.processGet",r),e(s.$tb.find('[data-cmd="spellChecker"]'))}function c(){var e=s.opts.scaytOptions;e.customerId=s.opts.scaytCustomerId,e.container=s.$iframe?s.$iframe.get(0):s.$el.get(0),e.autoStartup=s.opts.scaytAutoload,e.onLoad=i,null!==s.opts.language&&(s.opts.spellCheckerLanguage=s.opts.language),!0===s.opts.scaytAutoload&&(s.opts.spellcheck=!1),l=new SCAYT.CUSTOMSCAYT(e)}return{_init:function(){if(!s.$wp)return!1;if(s.opts.scaytOptions=a.extend({},a.FE.DEFAULT_SCAYT_OPTIONS,s.opts.scaytOptions),"undefined"!=typeof SCAYT)c();else if(s.shared.spellCheckerLoaded||(s.shared.spellCheckerCallbacks=[]),s.shared.spellCheckerCallbacks.push(c),!s.shared.spellCheckerLoaded){s.shared.spellCheckerLoaded=!0;var e=document.createElement("script");e.type="text/javascript",e.src=s.opts.scaytOptions.scriptPath,e.innerText="",e.onload=function(){for(var e=0;e<s.shared.spellCheckerCallbacks.length;e++)s.shared.spellCheckerCallbacks[e]()},document.getElementsByTagName("head")[0].appendChild(e)}},refresh:e,toggle:function(){l&&l.isDisabled&&l.setDisabled(!l.isDisabled())}}},a.FE.DefineIcon("spellChecker",{NAME:"keyboard-o",FA5NAME:"keyboard"}),a.FE.RegisterCommand("spellChecker",{title:"Spell Checker",undo:!1,focus:!1,accessibilityFocus:!0,forcedRefresh:!0,toggle:!0,callback:function(){this.spellChecker.toggle()},refresh:function(e){this.spellChecker.refresh(e)},plugin:"spellChecker"})});