text: /**
   * skylark-domx-contents - A dom plugin for  editing  the content of html element.
   * @author Hudaokeji Co.,Ltd
   * @version v0.9.0
   * @link www.skylarkjs.org
   * @license MIT
   */
  define(["skylark-langx/langx","skylark-domx-noder","skylark-domx-query","./contents"],function(e,t,n,i){var s=e.Evented.inherit({});return s.pluginName="Indentation",s.prototype.opts={tabIndent:!0,indentWidth:40},s.prototype.init=function(t,n){var i;this.editable=t,this.opts=e.extend({},this.opts,n),this.editable.keystroke.add("tab","*",(i=this,function(e){var t;if(t=i.editable.toolbar.findButton("code"),i.opts.tabIndent||t&&t.active)return i.indent(e.shiftKey)}))},s.prototype.indent=function(e){var i,s,r,o;return this.editable.selection.startNodes(),this.editable.selection.endNodes(),i=this.editable.selection.blockNodes(),s=[],i=i.each(function(e,n){var i,r,o,a,l;for(i=!0,r=o=0,a=s.length;o<a;r=++o){if(l=s[r],t.contains(n,l)){i=!1;break}if(t.contains(l,n)){s.splice(r,1,n),i=!1;break}}if(i)return s.push(n)}),i=n(s),r=!1,i.each((o=this,function(t,n){var i;if(i=e?o.outdentBlock(n):o.indentBlock(n))return r=i})),r},s.prototype.indentBlock=function(e){var t,i,s,r,o,a,l,d,h,c;if((t=n(e)).length){if(t.is("pre")){if(!(a=this.editable.selection.containerNode()).is(t)&&!a.closest("pre").is(t))return;this.indentText(this.editable.selection.range())}else if(t.is("li")){if((o=t.prev("li")).length<1)return;this.editable.selection.save(),c=t.parent()[0].tagName,(i=o.children("ul, ol")).length>0?i.append(t):n("<"+c+"/>").append(t).appendTo(o),this.editable.selection.restore()}else if(t.is("p, h1, h2, h3, h4"))h=parseInt(t.css("margin-left"))||0,h=(Math.round(h/this.opts.indentWidth)+1)*this.opts.indentWidth,t.css("margin-left",h);else{if(!t.is("table")&&!t.is("."+this.opts.classPrefix+"table"))return!1;if((s=(l=this.editable.selection.containerNode().closest("td, th")).next("td, th")).length>0||((r=(d=l.parent("tr")).next("tr")).length<1&&d.parent().is("thead")&&(r=d.parent("thead").next("tbody").find("tr:first")),s=r.find("td:first, th:first")),!(l.length>0&&s.length>0))return;this.editable.selection.setRangeAtEndOf(s)}return!0}},s.prototype.indentText=function(e){var t,n;return t=e.toString().replace(/^(?=.+)/gm,"  "),n=document.createTextNode(t||"  "),e.deleteContents(),e.insertNode(n),t?(e.selectNode(n),this.editable.selection.range(e)):this.editable.selection.setRangeAfter(n)},s.prototype.outdentBlock=function(e){var t,i,s,r,o,a,l,d,h,c;if((t=n(e))&&t.length>0){if(t.is("pre")){if(!(r=this.editable.selection.containerNode()).is(t)&&!r.closest("pre").is(t))return;this.outdentText(c)}else if(t.is("li"))s=(i=t.parent()).parent("li"),this.editable.selection.save(),s.length<1?((c=document.createRange()).setStartBefore(i[0]),c.setEndBefore(t[0]),i.before(c.extractContents()),n("<p/>").insertBefore(i).after(t.children("ul, ol")).append(t.contents()),t.remove()):(t.next("li").length>0&&n("<"+i[0].tagName+"/>").append(t.nextAll("li")).appendTo(t),t.insertAfter(s),i.children("li").length<1&&i.remove()),this.editable.selection.restore();else if(t.is("p, h1, h2, h3, h4"))h=parseInt(t.css("margin-left"))||0,h=Math.max(Math.round(h/this.opts.indentWidth)-1,0)*this.opts.indentWidth,t.css("margin-left",0===h?"":h);else{if(!t.is("table")&&!t.is("."+this.opts.classPrefix+"table"))return!1;if((o=(l=this.editable.selection.containerNode().closest("td, th")).prev("td, th")).length>0||((a=(d=l.parent("tr")).prev("tr")).length<1&&d.parent().is("tbody")&&(a=d.parent("tbody").prev("thead").find("tr:first")),o=a.find("td:last, th:last")),!(l.length>0&&o.length>0))return;this.editable.selection.setRangeAtEndOf(o)}return!0}},s.prototype.outdentText=function(e){},i.Indentation=s});
  //# sourceMappingURL=sourcemaps/indentation.js.map
  