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) • 2.42 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(r){"function"==typeof define&&define.amd?define(["jquery"],r):"object"==typeof module&&module.exports?module.exports=function(e,t){return t===undefined&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),r(t)}:r(window.jQuery)}(function(s){if(s.extend(s.FE.DEFAULTS,{aviaryKey:"542e1ff5d5144b9b81cef846574ba6cf",aviaryScriptURL:"https://dme0ih8comzn4.cloudfront.net/imaging/v3/editor.js",aviaryOptions:{displayImageSize:!0,theme:"minimum"}}),s.FE.PLUGINS.imageAviary=function(d){function i(){d.shared.feather_editor=new Aviary.Feather(s.extend({apiKey:d.opts.aviaryKey,onSave:function(e,t){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){var e=document.createElement("CANVAS"),t=e.getContext("2d");e.height=this.height,e.width=this.width,t.drawImage(this,0,0);for(var r=e.toDataURL("image/png"),i=atob(r.split(",")[1]),a=[],n=0;n<i.length;n++)a.push(i.charCodeAt(n));var o=new Blob([new Uint8Array(a)],{type:"image/png"});d.shared.feather_editor.instance.image.edit(s(d.shared.feather_editor.current_image)),d.shared.feather_editor.instance.image.upload([o]),d.shared.feather_editor.close()},r.src=t,d.shared.feather_editor.showWaitIndicator()},onError:function(e){throw new Error(e.message)},onClose:function(){d.shared.feather_editor.instance.image.get()||d.shared.feather_editor.instance.image.edit(s(d.shared.feather_editor.current_image))}},d.opts.aviaryOptions))}return{_init:function(){var e,t,r;d.shared.feather_editor||(d.shared.feather_editor=!0,"undefined"==typeof Aviary?(e=d.opts.aviaryScriptURL,t=i,(r=document.createElement("script")).type="text/javascript",r.defer="defer",r.src=e,r.innerText="",r.onload=t,document.getElementsByTagName("head")[0].appendChild(r)):i())},launch:function(e){"object"==typeof e.shared.feather_editor&&(e.shared.feather_editor.current_image=e.image.get()[0],(e.shared.feather_editor.instance=e).shared.feather_editor.launch({image:e.image.get()[0],url:e.image.get()[0].src}))}}},s.FE.DefineIcon("aviary",{NAME:"sliders",FA5NAME:"sliders-h"}),s.FE.RegisterCommand("aviary",{title:"Advanced Edit",undo:!1,focus:!1,callback:function(e,t){this.imageAviary.launch(this)},plugin:"imageAviary"}),!s.FE.PLUGINS.image)throw new Error("Image Aviary plugin requires image plugin.")});