text: /**
   * skylark-etch - A version of etch.js that ported to running on skylarkjs
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylark-integration/skylark-etch/
   * @license MIT
   */
  define(["skylark-langx/langx","skylark-underscore/underscore","skylark-backbone/View","../etch"],function(e,t,n,i){return i.views.Editor=n.extend({initialize:function(){this.$el=$(this.el),t.bindAll(this,"changeButtons","changePosition","changeEditable","insertImage"),this.model.bind("change:buttons",this.changeButtons),this.model.bind("change:position",this.changePosition),this.model.bind("change:editable",this.changeEditable),this.changeEditable()},events:{"click .etch-bold":"toggleBold","click .etch-superscript":"toggleSuperscript","click .etch-subscript":"toggleSubscript","click .etch-italic":"toggleItalic","click .etch-underline":"toggleUnderline","click .etch-heading":"toggleHeading","click .etch-unordered-list":"toggleUnorderedList","click .etch-justify-left":"justifyLeft","click .etch-justify-center":"justifyCenter","click .etch-justify-right":"justifyRight","click .etch-ordered-list":"toggleOrderedList","click .etch-link":"toggleLink","click .etch-image":"getImage","click .etch-save":"save","click .etch-clear-formatting":"clearFormatting"},changeEditable:function(){this.setButtonClass()},setButtonClass:function(){var e=this.model,t=e.get("editable").attr("data-button-class")||"default";e.set({buttons:i.config.buttonClasses[t]})},changeButtons:function(){this.$el.empty();var e=this;this.model.get("buttons").length?(t.each(this.model.get("buttons"),function(t){var n=$('<a href="#" class="etch-editor-button etch-'+t+'" title="'+t.replace("-"," ")+'"><span></span></a>');e.$el.append(n)}),$(this.el).show("fast")):$(this.el).hide()},changePosition:function(){var e=this.model.get("position");this.$el.animate({top:e.y,left:e.x},{queue:!1})},wrapSelection:function(e,t,n){var i=e===Range?e:e.getRangeAt(0),l=document.createElement(t);i.surroundContents(l)},clearFormatting:function(e){e.preventDefault(),document.execCommand("removeFormat",!1,null)},toggleBold:function(e){e.preventDefault(),document.execCommand("bold",!1,null)},toggleSubscript:function(e){e.preventDefault(),document.execCommand("subscript",!1,null)},toggleSuperscript:function(e){e.preventDefault(),document.execCommand("superscript",!1,null)},toggleItalic:function(e){e.preventDefault(),document.execCommand("italic",!1,null)},toggleUnderline:function(e){e.preventDefault(),document.execCommand("underline",!1,null)},toggleHeading:function(e){e.preventDefault();var t=window.getSelection().getRangeAt(0),n=t.commonAncestorContainer.parentElement;if($(n).is("h3"))$(n).replaceWith(n.textContent);else{var i=document.createElement("h3");t.surroundContents(i)}},urlPrompt:function(e){var t=prompt("Enter a url","http://");null!==t&&(/^((http|https)...)/.test(t)?e(t):e("http://"+t))},toggleLink:function(e){e.preventDefault();var t=window.getSelection().getRangeAt(0);"A"===t.startContainer.parentNode.tagName||"A"===t.endContainer.parentNode.tagName?document.execCommand("unlink",!1,null):this.urlPrompt(function(e){document.execCommand("createLink",!1,e)})},toggleUnorderedList:function(e){e.preventDefault(),document.execCommand("insertUnorderedList",!1,null)},toggleOrderedList:function(e){e.preventDefault(),document.execCommand("insertOrderedList",!1,null)},justifyLeft:function(e){e.preventDefault(),document.execCommand("justifyLeft",!1,null)},justifyCenter:function(e){e.preventDefault(),document.execCommand("justifyCenter",!1,null)},justifyRight:function(e){e.preventDefault(),document.execCommand("justifyRight",!1,null)},getImage:function(e){e.preventDefault(),this.startUploader(this.insertImage)},startUploader:function(e){var t=new models.ImageUploader,n=new views.ImageUploader({model:t});t._imageCallback=function(t){n.startCropper(t,e)},this._savedRange=window.getSelection().getRangeAt(0),$("body").append(n.render().el)},insertImage:function(e){var n=window.getSelection();n.removeAllRanges(),n.addRange(this._savedRange);var i={editable:this.model.get("editable"),editableModel:this.model.get("editableModel")};t.extend(i,e);var l=new models.EditableImage(i),o=new views.EditableImage({model:l});this._savedRange.insertNode($(o.render().el).addClass("etch-float-left")[0])},save:function(e){e.preventDefault(),this.model.get("editableModel").trigger("save")}})});
  //# sourceMappingURL=../sourcemaps/views/Editor.js.map
  