/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:28
*/
/*
 thanks to CKSource's intelligent work on CKEditor
 @author yiminghe@gmail.com
*/
KISSY.add("editor/core/base",function(d,h,r){h=r.Controller.extend({initializer:function(){this.__commands={};this.__controls={}}},{Config:{},XHTML_DTD:h.DTD,ATTRS:{textarea:{},iframe:{},window:{},document:{},toolBarEl:{},statusBarEl:{},handleMouseEvents:{value:!1},focusable:{value:!1},mode:{value:1},data:{getter:function(){return this._getData()},setter:function(d){return this._setData(d)}},formatData:{getter:function(){return this._getData(1)},setter:function(d){return this._setData(d)}},customStyle:{value:""},
customLink:{value:[]}}},{xclass:"editor"});h.HTML_PARSER={textarea:function(d){return d.one(".ks-editor-textarea")}};d.mix(h,d.EventTarget);return KISSY.Editor=h},{requires:["htmlparser","component","core"]});
KISSY.add("editor/core/clipboard",function(d,h,r,s){function q(a){this.editor=a;this._init()}function i(a){if(k.ie&&"BackCompat"!=a.get("document")[0].compatMode){var e=a.getSelection(),f;if(e.getType()==s.SELECTION_ELEMENT&&(f=e.getSelectedElement())){var c=e.getRanges()[0],j=b(a.get("document")[0].createTextNode(""));j.insertBefore(f);c.setStartBefore(j);c.setEndAfter(f);e.selectRanges([c]);setTimeout(function(){f.parent()&&(j.remove(),e.selectElement(f))},0)}}}var b=d.all,k=d.UA,n=h.RANGE,m=d.Event;
d.augment(q,{_init:function(){var a=this.editor,b=a.get("document")[0].body;m.on(b,k.ie?"beforepaste":"paste",this._paste,this);m.on(b,"contextmenu",function(){e=1;setTimeout(function(){e=0},10)});a.addCommand("copy",new t("copy"));a.addCommand("cut",new t("cut"));a.addCommand("paste",new t("paste"))},_paste:function(){if(!e){var a=this.editor,p=a.get("document")[0];if(!p.getElementById("ke_pastebin")){var f=a.getSelection(),c=new r(p),j=b(k.webkit?"<body></body>":"<div></div>",null,p);j.attr("id",
"ke_pastebin");k.webkit&&j[0].appendChild(p.createTextNode("\u00a0"));p.body.appendChild(j[0]);j.css({position:"absolute",top:f.getStartElement().offset().top+"px",width:"1px",height:"1px",overflow:"hidden"});j.css("left","-1000px");var l=f.createBookmarks();c.setStartAt(j,n.POSITION_AFTER_START);c.setEndAt(j,n.POSITION_BEFORE_END);c.select(!0);setTimeout(function(){var c;j=k.webkit&&(c=j.first())&&c.hasClass("Apple-style-span")?c:j;f.selectBookmarks(l);j.remove();var e=j.html();if(e=d.trim(e.replace(/<span[^>]+_ke_bookmark[^<]*?<\/span>(&nbsp;)*/ig,
"")))c=a.fire("paste",{html:e,holder:j}),void 0!==c&&(e=c),/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument)/.test(e)?d.use("editor/core/dynamic/wordFilter",function(j,c){a.insertHtml(c.toDataFormat(e,a))}):a.insertHtml(e)},0)}}}});var u=function(a,e){var f=a.get("document")[0],c=b(f.body),j=!1,l=function(){j=!0};c.on(e,l);(7<k.ie?f:f.selection.createRange()).execCommand(e);c.detach(e,l);return j},o=k.ie?function(a,e){return u(a,e)}:function(a,e){try{return a.get("document")[0].execCommand(e)}catch(f){return!1}},
v={cut:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u526a\u5207\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+X)\u6765\u5b8c\u6210",copy:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u590d\u5236\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+C)\u6765\u5b8c\u6210",paste:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u7f16\u8f91\u5668\u81ea\u52a8\u6267\u884c\u7c98\u8d34\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl/Cmd+V)\u6765\u5b8c\u6210"},t=function(a){this.type=a};t.prototype={exec:function(a){"cut"==this.type&&i(a);(a=o(a,this.type))||alert(v[this.type]);return a}};var a={copy:"\u590d\u5236",paste:"\u7c98\u8d34",cut:"\u526a\u5207"},e;return{init:function(e){e.docReady(function(){new q(e)});var b={copy:1,cut:1,paste:1};e.on("contextmenu",function(f){f=f.contextmenu;if(!f.__copy_fix){f.__copy_fix=
1;for(var c in b)b.hasOwnProperty(c)&&f.addChild({xclass:"menuitem",content:a[c],value:c});f.on("click",function(a){var c=a.target.get("value");b[c]&&(this.hide(),setTimeout(function(){e.execCommand(c)},30))})}})}}},{requires:["./base","./range","./selection"]});
KISSY.add("editor/core/dom",function(d,h,r){function s(a,e){var g=a[e?"next":"prev"](q,1);if(g&&g[0].nodeType==b.ELEMENT_NODE){for(var p=[];g.attr("_ke_bookmark")||g._4e_isEmptyInlineRemovable(q);)if(p.push(g),g=e?g.next(q,1):g.prev(q,1),!g)return;if(a._4e_isIdentical(g,q)){for(var f=new n(e?a[0].lastChild:a[0].firstChild);p.length;)p.shift()._4e_move(a,!e,q);g._4e_moveChildren(a,!e,q);g.remove();f[0]&&f[0].nodeType==b.ELEMENT_NODE&&f._4e_mergeSiblings()}}}var q=q,i=h.XHTML_DTD,b=d.DOM,k=d.UA,n=d.Node,
m={a:1,abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1};h.POSITION={POSITION_IDENTICAL:0,POSITION_DISCONNECTED:1,POSITION_FOLLOWING:2,POSITION_PRECEDING:4,POSITION_IS_CONTAINED:8,POSITION_CONTAINS:16};var u=h.POSITION,o={block:1,"list-item":1,table:1,"table-row-group":1,"table-header-group":1,"table-footer-group":1,"table-row":1,"table-column-group":1,"table-column":1,
"table-cell":1,"table-caption":1},v={hr:1},t=function(a){return a&&(a[0]||a)};r.injectDom({_4e_sameLevel:function(a,e){var e=t(e),g=a.parentNode;return g&&g==e.parentNode},_4e_isBlockBoundary:function(a,e){var g=d.merge(v,e);return!(!o[b.css(a,"display")]&&!g[b.nodeName(a)])},_4e_index:function(a,e){for(var g=a.parentNode.childNodes,b,f=-1,c=0;c<g.length;c++)if(b=g[c],!e||!(3==b.nodeType&&b.previousSibling&&3==b.previousSibling.nodeType))if(f++,b===a)return f;return-1},_4e_move:function(a,e,g){e=
t(e);g?e.insertBefore(a,e.firstChild):e.appendChild(a)},_4e_isIdentical:function(a,e){if(!e)return!1;e=t(e);if(b.nodeName(a)!=b.nodeName(e))return!1;var g=a.attributes,p=e.attributes,f=g.length,c=p.length;if(f!=c)return!1;for(var j=0;j<f;j++){var l=g[j],w=l.name;if(l.specified&&b.attr(a,w)!=b.attr(e,w))return!1}if(8>r.ieEngine)for(j=0;j<c;j++)if(l=p[j],w=l.name,l.specified&&b.attr(a,w)!=b.attr(e,w))return!1;return!0},_4e_isEmptyInlineRemovable:function(a){if(!i.$removeEmpty[b.nodeName(a)])return!1;
for(var a=a.childNodes,e=0,g=a.length;e<g;e++){var p=a[e],f=p.nodeType;if(!(f==b.ELEMENT_NODE&&p.getAttribute("_ke_bookmark"))&&(f==b.ELEMENT_NODE&&!b._4e_isEmptyInlineRemovable(p)||f==b.TEXT_NODE&&d.trim(p.nodeValue)))return!1}return!0},_4e_moveChildren:function(a,e,g){e=t(e);if(a!=e)if(g)for(;g=a.lastChild;)e.insertBefore(a.removeChild(g),e.firstChild);else for(;g=a.firstChild;)e.appendChild(a.removeChild(g))},_4e_mergeSiblings:function(a){a=new n(a);m[a.nodeName()]&&(s(a,!0),s(a))},_4e_splitText:function(a,
e){var g=a.ownerDocument;if(a.nodeType==b.TEXT_NODE){if(k.ie&&e==a.nodeValue.length){var p=g.createTextNode("");b.insertAfter(p,a);return p}p=a.splitText(e);g.documentMode&&(g=g.createTextNode(""),b.insertAfter(g,p),b.remove(g));return p}},_4e_parents:function(a,e){var g=[];g.__IS_NODELIST=1;do g[e?"push":"unshift"](a);while(a=a.parentNode);return g},_4e_nextSourceNode:function(a,e,g,p){if(p&&!p.call)var f=t(p),p=function(a){return a!==f};var e=!e&&a.firstChild,c=a;if(!e){if(a.nodeType==b.ELEMENT_NODE&&
p&&!1===p(a,!0))return null;e=a.nextSibling}for(;!e&&(c=c.parentNode);){if(p&&!1===p(c,!0))return null;e=c.nextSibling}return!e||p&&!1===p(e)?null:g&&g!=e.nodeType?b._4e_nextSourceNode(e,!1,g,p):e},_4e_previousSourceNode:function(a,e,g,p){if(p&&!p.call)var f=t(p),p=function(a){return a!==f};var e=!e&&a.lastChild,c=a;if(!e){if(a.nodeType==b.ELEMENT_NODE&&p&&!1===p(a,!0))return null;e=a.previousSibling}for(;!e&&(c=c.parentNode);){if(p&&!1===p(c,!0))return null;e=c.previousSibling}return!e||p&&!1===
p(e)?null:g&&e.nodeType!=g?b._4e_previousSourceNode(e,!1,g,p):e},_4e_commonAncestor:function(a,e){e=t(e);if(a===e)return a;if(b.contains(e,a))return e;var g=a;do if(b.contains(g,e))return g;while(g=g.parentNode);return null},_4e_hasAttributes:9>r.ieEngine?function(a){for(var e=a.attributes,g=0;g<e.length;g++){var b=e[g];switch(b.name){case "class":if(a.getAttribute("class"))return!0;break;default:if(b.specified)return!0}}return!1}:function(a){k.gecko&&a.removeAttribute("_moz_dirty");return a.hasAttributes()},
_4e_position:function(a,e){var g=t(e);if(a.compareDocumentPosition)return a.compareDocumentPosition(g);if(a==g)return u.POSITION_IDENTICAL;if(a.nodeType==b.ELEMENT_NODE&&g.nodeType==b.ELEMENT_NODE){if(b.contains(a,g))return u.POSITION_CONTAINS+u.POSITION_PRECEDING;if(b.contains(g,a))return u.POSITION_IS_CONTAINED+u.POSITION_FOLLOWING;if("sourceIndex"in a)return 0>a.sourceIndex||0>g.sourceIndex?u.POSITION_DISCONNECTED:a.sourceIndex<g.sourceIndex?u.POSITION_PRECEDING:u.POSITION_FOLLOWING}for(var d=
b._4e_address(a),g=b._4e_address(g),f=Math.min(d.length,g.length),c=0;c<=f-1;c++)if(d[c]!=g[c])return d[c]<g[c]?u.POSITION_PRECEDING:u.POSITION_FOLLOWING;return d.length<g.length?u.POSITION_CONTAINS+u.POSITION_PRECEDING:u.POSITION_IS_CONTAINED+u.POSITION_FOLLOWING},_4e_address:function(a,e){for(var g=[],d=a.ownerDocument.documentElement,f=a;f&&f!=d;)g.unshift(b._4e_index(f,e)),f=f.parentNode;return g},_4e_remove:function(a,e){var g=a.parentNode;if(g){if(e)for(var b;b=a.firstChild;)g.insertBefore(a.removeChild(b),
a);g.removeChild(a)}return a},_4e_trim:function(a){b._4e_ltrim(a);b._4e_rtrim(a)},_4e_ltrim:function(a){for(var e;e=a.firstChild;){if(e.nodeType==b.TEXT_NODE){var g=r.ltrim(e.nodeValue),d=e.nodeValue.length;if(g)g.length<d&&(b._4e_splitText(e,d-g.length),a.removeChild(a.firstChild));else{a.removeChild(e);continue}}break}},_4e_rtrim:function(a){for(var e;e=a.lastChild;){if(e.type==b.TEXT_NODE){var g=r.rtrim(e.nodeValue),d=e.nodeValue.length;if(g)g.length<d&&(b._4e_splitText(e,g.length),a.removeChild(a.lastChild));
else{a.removeChild(e);continue}}break}!k.ie&&!k.opera&&(e=a.lastChild)&&1==e.nodeType&&"br"==b.nodeName(e)&&a.removeChild(e)},_4e_appendBogus:function(a){for(var e=a.lastChild;e&&e.nodeType==b.TEXT_NODE&&!d.trim(e.nodeValue);)e=e.previousSibling;if(!e||e.nodeType==b.TEXT_NODE||"br"!==b.nodeName(e))e=k.opera?a.ownerDocument.createTextNode(""):a.ownerDocument.createElement("br"),k.gecko&&e.setAttribute("type","_moz"),a.appendChild(e)},_4e_outerHtml:function(a){if(a.outerHTML)return a.outerHTML.replace(/<\?[^>]*>/,
"");var e=a.ownerDocument.createElement("div");e.appendChild(a.cloneNode(!0));return e.innerHTML},_4e_setMarker:function(a,e,g,b){var a=new n(a),f=a.data("list_marker_id")||a.data("list_marker_id",d.guid()).data("list_marker_id"),c=a.data("list_marker_names")||a.data("list_marker_names",{}).data("list_marker_names");e[f]=a;c[g]=1;return a.data(g,b)},_4e_clearMarkers:function(a,e,g){var a=new n(a),b=a.data("list_marker_names"),f=a.data("list_marker_id"),c;for(c in b)b.hasOwnProperty(c)&&a.removeData(c);
a.removeData("list_marker_names");g&&(a.removeData("list_marker_id"),delete e[f])},_4e_copyAttributes:function(a,e,g){for(var e=new n(e),d=a.attributes,g=g||{},f=0;f<d.length;f++){var c=d[f],j=c.name.toLowerCase(),l;if(!(j in g))if("checked"==j&&(l=b.attr(a,j)))e.attr(j,l);else if(c.specified||k.ie&&c.value&&"value"==j)l=b.attr(a,j),null===l&&(l=c.nodeValue),e.attr(j,l)}""!==a.style.cssText&&(e[0].style.cssText=a.style.cssText)},_4e_isEditable:function(a){a=b.nodeName(a);return(a=!i.$nonEditable[a]&&
(i[a]||i.span))&&a["#text"]},_4e_getByAddress:function(a,e,g){for(var a=a.documentElement,b=0;a&&b<e.length;b++){var f=e[b];if(g)for(var c=-1,j=0;j<a.childNodes.length;j++){var l=a.childNodes[j];if(!(!0===g&&3==l.nodeType&&l.previousSibling&&3==l.previousSibling.nodeType)&&(c++,c==f)){a=l;break}}else a=a.childNodes[f]}return a}})},{requires:["./base","./utils"]});
KISSY.add("editor/core/domIterator",function(d){function h(b){1>arguments.length||(this.range=b,this.forceBrBreak=s,this.enlargeBr=r,this.enforceRealBlocks=s,this._||(this._={}))}var r=!0,s=!1,q=d.Editor,i=d.UA,b=q.Walker,k=q.Range,n=q.RANGE,m=q.ElementPath,u=d.Node,o=d.DOM,v=/^[\r\n\t ]*$/;d.augment(h,{getNextParagraph:function(h){var a,e,g,p,f;if(!this._.lastNode){e=this.range.clone();e.shrink(n.SHRINK_ELEMENT,r);e.enlarge(this.forceBrBreak||!this.enlargeBr?n.ENLARGE_LIST_ITEM_CONTENTS:n.ENLARGE_BLOCK_CONTENTS);
var c=new b(e),j=b.bookmark(r,r);c.evaluator=j;this._.nextNode=c.next();c=new b(e);c.evaluator=j;c=c.previous();this._.lastNode=c._4e_nextSourceNode(r);this._.lastNode&&this._.lastNode[0].nodeType==o.TEXT_NODE&&!d.trim(this._.lastNode[0].nodeValue)&&this._.lastNode.parent()._4e_isBlockBoundary()&&(j=new k(e.document),j.moveToPosition(this._.lastNode,n.POSITION_AFTER_END),j.checkEndOfBlock()&&(j=new m(j.endContainer),this._.lastNode=(j.block||j.blockLimit)._4e_nextSourceNode(r)));this._.lastNode||
(this._.lastNode=this._.docEndMarker=new u(e.document.createTextNode("")),o.insertAfter(this._.lastNode[0],c[0]));e=null}j=this._.nextNode;c=this._.lastNode;for(this._.nextNode=null;j;){var l=s,w=j[0].nodeType!=o.ELEMENT_NODE,x=s;if(w)j[0].nodeType==o.TEXT_NODE&&v.test(j[0].nodeValue)&&(w=s);else{var y=j.nodeName();if(j._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){if("br"==y)w=r;else if(!e&&!j[0].childNodes.length&&"hr"!=y){a=j;g=j.equals(c);break}e&&(e.setEndAt(j,n.POSITION_BEFORE_START),"br"!=
y&&(this._.nextNode=j));l=r}else{if(j[0].firstChild){e||(e=new k(this.range.document),e.setStartAt(j,n.POSITION_BEFORE_START));j=new u(j[0].firstChild);continue}w=r}}w&&!e&&(e=new k(this.range.document),e.setStartAt(j,n.POSITION_BEFORE_START));g=(!l||w)&&j.equals(c);if(e&&!l)for(;!j[0].nextSibling&&!g;){y=j.parent();if(y._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){l=r;g||y.equals(c);break}j=y;w=r;g=j.equals(c);x=r}w&&e.setEndAt(j,n.POSITION_AFTER_END);j=j._4e_nextSourceNode(x,null,c);if((g=!j)||
l&&e)break}if(!a){if(!e)return this._.docEndMarker&&this._.docEndMarker._4e_remove(),this._.nextNode=null;a=new m(e.startContainer);j=a.blockLimit;l={div:1,th:1,td:1};a=a.block;if((!a||!a[0])&&!this.enforceRealBlocks&&l[j.nodeName()]&&e.checkStartOfBlock()&&e.checkEndOfBlock())a=j;else if(!a||this.enforceRealBlocks&&"li"==a.nodeName())a=new u(this.range.document.createElement(h||"p")),a[0].appendChild(e.extractContents()),a._4e_trim(),e.insertNode(a),p=f=r;else if("li"!=a.nodeName()){if(!e.checkStartOfBlock()||
!e.checkEndOfBlock())a=a.clone(s),a[0].appendChild(e.extractContents()),a._4e_trim(),f=e.splitBlock(),p=!f.wasStartOfBlock,f=!f.wasEndOfBlock,e.insertNode(a)}else g||(this._.nextNode=a.equals(c)?null:e.getBoundaryNodes().endNode._4e_nextSourceNode(r,null,c))}p&&(e=new u(a[0].previousSibling),e[0]&&e[0].nodeType==o.ELEMENT_NODE&&("br"==e.nodeName()?e._4e_remove():e[0].lastChild&&"br"==o.nodeName(e[0].lastChild)&&o._4e_remove(e[0].lastChild)));f&&(e=b.bookmark(s,r),p=new u(a[0].lastChild),p[0]&&p[0].nodeType==
o.ELEMENT_NODE&&"br"==p.nodeName()&&(i.ie||p.prev(e,1)||p.next(e,1))&&p.remove());this._.nextNode||(this._.nextNode=g||a.equals(c)?null:a._4e_nextSourceNode(r,null,c));return a}});k.prototype.createIterator=function(){return new h(this)};return h},{requires:["./base","./range","./elementPath","./walker"]});
KISSY.add("editor/core/elementPath",function(d){function h(d){for(var m=i,h=i,o=[];d;){if(d[0].nodeType==s.ELEMENT_NODE){this.lastElement||(this.lastElement=d);var v=d.nodeName();if(!h&&(!m&&b[v]&&(m=d),k[v])){var t;if(t=!m)if(t="div"==v){a:{t=d[0].childNodes;for(var a=0,e=t.length;a<e;a++){var g=t[a];if(g.nodeType==s.ELEMENT_NODE&&q.$block[g.nodeName.toLowerCase()]){t=!0;break a}}t=!1}t=!t}t?m=d:h=d}o.push(d);if("body"==v)break}d=d.parent()}this.block=m;this.blockLimit=h;this.elements=o}var r=d.Editor,
s=d.DOM,q=r.XHTML_DTD,i=null,b={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1},k={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1};h.prototype={compare:function(b){var d=this.elements,b=b&&b.elements;if(!b||d.length!=b.length)return!1;for(var i=0;i<d.length;i++)if(!s.equals(d[i],b[i]))return!1;return!0},contains:function(b){for(var d=this.elements,k=0;k<d.length;k++)if(d[k].nodeName()in b)return d[k];return i},toString:function(){var b=this.elements,
d,i=[];for(d=0;d<b.length;d++)i.push(b[d].nodeName());return i.toString()}};return r.ElementPath=h},{requires:["./base","./dom"]});
KISSY.add("editor/core/enterKey",function(d,h,r,s){function q(i){var h;h=i.getSelection().getRanges();for(var t=h.length-1;0<t;t--)h[t].deleteContents();h=h[0];t=h.document;if(h.checkStartOfBlock()&&h.checkEndOfBlock()){var a=(new s(h.startContainer)).block;if(a&&("li"==a.nodeName()||"li"==a.parent().nodeName()))return i.hasCommand("outdent")?(i.execCommand("save"),i.execCommand("outdent"),i.execCommand("save"),!0):!1}var e=h.splitBlock("p");if(!e)return!0;var i=e.previousBlock,a=e.nextBlock,g=e.wasStartOfBlock,
p=e.wasEndOfBlock,f;if(a)f=a.parent(),"li"==f.nodeName()&&(a._4e_breakParent(f),a._4e_move(a.next(),!0));else if(i&&(f=i.parent())&&"li"==f.nodeName())i._4e_breakParent(f),h.moveToElementEditablePosition(i.next()),i._4e_move(i.prev());if(!g&&!p){if("li"==a.nodeName()&&(f=a.first(r.invisible(!0)))&&d.inArray(f.nodeName(),["ul","ol"]))(b.ie?new m(t.createTextNode("\u00a0")):new m(t.createElement("br"))).insertBefore(f);a&&h.moveToElementEditablePosition(a)}else{var c;if(i){if("li"==i.nodeName()||!k.test(i.nodeName()))c=
i.clone()}else a&&(c=a.clone());c||(c=new m("<p>",null,t));if(f=e.elementPath)for(var e=0,j=f.elements.length;e<j;e++){var l=f.elements[e];if(l.equals(f.block)||l.equals(f.blockLimit))break;n.$removeEmpty[l.nodeName()]&&(l=l.clone(),c._4e_moveChildren(l),c.append(l))}b.ie||c._4e_appendBogus();h.insertNode(c);if(b.ie&&g&&(!p||!i[0].childNodes.length))h.moveToElementEditablePosition(p?i:c),h.select();h.moveToElementEditablePosition(g&&!p?a:c)}b.ie||(a?(c=new m(t.createElement("span")),c.html("&nbsp;"),
h.insertNode(c),c.scrollIntoView(void 0,!1),h.deleteContents()):c.scrollIntoView(void 0,!1));h.select();return!0}function i(b){var d=b.get("document")[0];u.on(d,"keydown",function(d){if(13===d.keyCode&&!d.shiftKey&&!d.ctrlKey&&!d.metaKey){b.execCommand("save");var a=b.execCommand("enterBlock");b.execCommand("save");!1!==a&&d.preventDefault()}})}var b=d.UA,k=/^h[1-6]$/,n=h.XHTML_DTD,m=d.Node,u=d.Event;return{init:function(b){b.addCommand("enterBlock",{exec:q});b.docReady(function(){i(b)})}}},{requires:["./base",
"./walker","./elementPath"]});
KISSY.add("editor/core/focusManager",function(d){function h(){var d=this;d.__iframeFocus=n;k=d;b&&clearTimeout(b);b=setTimeout(function(){d.fire("focus")},100)}function r(){var d=this;d.__iframeFocus=m;k=u;b&&clearTimeout(b);b=setTimeout(function(){d.fire("blur")},100)}var s=d.Editor,q=d.Event,i={},b,k,d={refreshAll:function(){for(var b in i)if(i.hasOwnProperty(b)){var d=i[b].get("document")[0];d.designMode="off";d.designMode="on"}},currentInstance:function(){return k},getInstance:function(b){return i[b]},
add:function(b){var d=b.get("window")[0];q.on(d,"focus",h,b);q.on(d,"blur",r,b)},register:function(b){i[b._UUID]=b},remove:function(b){delete i[b._UUID];var d=b.get("window")[0];q.remove(d,"focus",h,b);q.remove(d,"blur",r,b)}},n=!0,m=!1,u=null;d.refreshAll=d.refreshAll;s.focusManager=d;s.getInstances=function(){return i};return d},{requires:["./base","./dom"]});
KISSY.add("editor/core/htmlDataProcessor",function(d,h){return{init:function(r){function s(a){if((a.getAttribute("class")+"").match(/Apple-\w+-span/)||!a.attributes.length)a.setTagName(null);else if(!a.childNodes.length&&!a.attributes.length)return!1}function q(a){return a.replace(v,function(a,c,e){return"<"+c+e.replace(t,function(a,c){return-1==e.indexOf("_ke_saved_"+c)?" _ke_saved_"+a+" "+a:a})+">"})}function i(a){return a.replace(e,function(a){return"<ke:encoded>"+encodeURIComponent(a)+"</ke:encoded>"})}
function b(a){return a.replace(g,function(a,c){return decodeURIComponent(c)})}var k=d.Node,n=d.UA,m=d.require("htmlparser"),u=new m.Filter,o=new m.Filter;(function(){function c(e){e=m.serialize(e);return new m.Comment(a+encodeURIComponent(e).replace(/--/g,"%2D%2D"))}var e={tagNames:[[/^\?xml.*$/i,""],[/^.*namespace.*$/i,""]],attributeNames:[[/^on/,"ke_on"],[/^lang$/,""]],tags:{script:c,noscript:c,span:s}},b={tagNames:[[/^ke:/,""],[/^\?xml:namespace$/,""]],tags:{$:function(a){if(a.attributes.length)for(var c=
["name","href","src"],e,b=0;b<c.length;b++)e="_ke_saved_"+c[b],a.getAttribute(e)&&a.removeAttribute(c[b]);return a},embed:function(a){var c=a.parentNode;if(c&&"object"==c.nodeName){var e=c.getAttribute("width"),c=c.getAttribute("height");e&&a.setAttribute("width",e);c&&a.setAttribute("width",c)}},a:function(a){if(!a.childNodes.length&&!a.attributes.length)return!1},span:s},attributes:{style:function(a){if(!d.trim(a))return!1}},attributeNames:[[/^_ke_saved_/,""],[/^ke_on/,"on"],[/^_ke.*/,""],[/^ke:.*$/,
""],[/^_ks.*/,""]],comment:function(c){if(c.substr(0,a.length)==a)return c=d.trim(decodeURIComponent(c.substr(a.length))),m.parse(c).childNodes[0]}};n.ie&&(b.attributes.style=function(a){return a.replace(/(^|;)([^:]+)/g,function(a){return a.toLowerCase()})});u.addRules(b);o.addRules(e)})();(function(){function a(c){for(var c=c.childNodes,e=c.length,B=c[e-1];B&&3==B.nodeType&&!d.trim(B.nodeValue);)B=c[--e];return B}function c(B,e){var b=a(B);b&&((e||!n.ie)&&1==b.nodeType&&"br"==b.nodeName?B.removeChild(b):
3==b.nodeType&&f.test(b.nodeValue)&&B.removeChild(b))}function e(c){var B=a(c);return!B||1==B.nodeType&&"br"==B.nodeName||"form"==c.nodeName&&"input"==B.nodeName}function b(a){c(a,!0);e(a)&&(n.ie?a.appendChild(new m.Text("\u00a0")):(a.appendChild(new m.Text("&nbsp;")),a.appendChild(new m.Tag("br"))))}function g(a){c(a,!1);e(a)&&a.appendChild(new m.Text("\u00a0"))}var f=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,i=h.XHTML_DTD,B=d.merge(i.$block,i.$listItem,i.$tableContent),z;for(z in B)B.hasOwnProperty(z)&&("br"in i[z]||
delete B[z]);delete B.td;delete B.pre;var i={tags:{}},G={tags:{}};for(z in B)B.hasOwnProperty(z)&&(i.tags[z]=b,G.tags[z]=g);o.addRules(i);u.addRules(G)})();u.addRules({text:function(a){return a.replace(/\xa0/g,"&nbsp;")}});var v=/<(a|area|img|input)\b([^>]*)>/gi,t=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,a="{ke_protected}",e=/(?:<style[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,g=/<ke:encoded>([^<]*)<\/ke:encoded>/gi,p=/(<\/?)((?:object|embed|param|html|body|head|title|script|noscript)[^>]*>)/gi,
f=/(<\/?)ke:((?:object|embed|param|html|body|head|title|script|noscript)[^>]*>)/gi,c=/<ke:(param|embed)([^>]*?)\/?>(?!\s*<\/ke:\1)/gi;r.htmlDataProcessor={dataFilter:o,htmlFilter:u,toHtml:function(a){var c=new m.BeautifyWriter;(new m.Parser(a)).parse().writeHtml(c,u);return a=c.getHtml()},toDataFormat:function(a,e){var e=e||o,a=q(a),a=i(a),a=a.replace(p,"$1ke:$2"),a=a.replace(c,"<ke:$1$2></ke:$1>"),g=new k("<div>");g.html("a"+a);a=g.html().substr(1);a=a.replace(f,"$1$2");a=b(a);g=new m.BasicWriter;
(new m.Parser(a)).parse().writeHtml(g,e);return a=g.getHtml()},toServer:function(a){var c=new m.MinifyWriter;(new m.Parser(a)).parse().writeHtml(c,u);return c.getHtml()}}}}},{requires:["./base"]});
KISSY.add("editor/core/meta",function(){var d={backColor:["../color/btn","./cmd"],localStorage:["../flashBridge/"],bold:["../font/ui","./cmd"],draft:["../localStorage/","../menubutton/"],flash:["../flashCommon/baseClass","../flashCommon/utils"],fontFamily:["../font/ui","./cmd"],fontSize:["../font/ui","./cmd"],foreColor:["../color/btn","./cmd"],heading:["./cmd"],image:["../button/","../bubble/","../contextmenu/","../dialogLoader/"],indent:["./cmd"],orderedList:["../listUtils/btn","./cmd"],unorderedList:["../listUtils/btn",
"./cmd"],italic:["../font/ui","./cmd"],justifyCenter:["./cmd"],justifyLeft:["./cmd"],justifyRight:["./cmd"],link:["../bubble/","./utils","../dialogLoader/"],maximize:["./cmd"],multipleUpload:["../dialogLoader/"],outdent:["./cmd"],overlay:["dd","../focusFix/"],pageBreak:["../fakeObjects/"],removeFormat:["./cmd","../button/"],resize:["dd"],menubutton:["menubutton"],smiley:["../overlay/"],sourceArea:["../button/"],strikeThrough:["../font/ui","./cmd"],table:["../dialogLoader/","../contextmenu/"],underline:["../font/ui",
"./cmd"],undo:["./btn","./cmd"],contextmenu:["menu","../focusFix/"],video:["../flashCommon/utils","../flashCommon/baseClass"],xiamiMusic:["../flashCommon/baseClass","../flashCommon/utils"]},h,r,s={"backColor/cmd":["../color/cmd"],"bold/cmd":["../font/cmd"],"color/btn":["../button/","../overlay/","../dialogLoader/"],"color/colorPicker/dialog":["../../overlay/"],"dentUtils/cmd":["../listUtils/"],"flash/dialog":["../flashCommon/utils","../overlay/","../menubutton/"],"flashCommon/baseClass":["../contextmenu/",
"../bubble/","../dialogLoader/","./utils"],"font/ui":["../button/","../menubutton/"],"fontFamily/cmd":["../font/cmd"],"fontSize/cmd":["../font/cmd"],"foreColor/cmd":["../color/cmd"],"image/dialog":["../overlay/","switchable","../menubutton/"],"indent/cmd":["../dentUtils/cmd"],"orderedList/cmd":["../listUtils/cmd"],"unorderedList/cmd":["../listUtils/cmd"],"italic/cmd":["../font/cmd"],"justifyCenter/cmd":["../justifyUtils/cmd"],"justifyLeft/cmd":["../justifyUtils/cmd"],"justifyRight/cmd":["../justifyUtils/cmd"],
"link/dialog":["../overlay/","./utils"],"listUtils/btn":["../button/"],"listUtils/cmd":["../listUtils/"],"multipleUpload/dialog":["../progressbar/","../overlay/","../flashBridge/","../localStorage/"],"outdent/cmd":["../dentUtils/cmd"],"strikeThrough/cmd":["../font/cmd"],"table/dialog":["../overlay/","../menubutton/"],"underline/cmd":["../font/cmd"],"undo/btn":["../button/"],"video/dialog":["../flash/dialog","../menubutton/"],"xiamiMusic/dialog":["../flash/dialog","../menubutton/"]},q={};for(h in d)r=
"editor/plugin/"+h+"/index",q[r]={requires:d[h]};for(h in s)r="editor/plugin/"+h,q[r]={requires:s[h]};KISSY.add(q)});
KISSY.add("editor/core/range",function(d,h,r,s,q){function i(a){var c=a.nodeType!=g.TEXT_NODE&&g.nodeName(a)in f.$removeEmpty,e=a.nodeType==g.TEXT_NODE&&!d.trim(a.nodeValue),a=!!a.parentNode.getAttribute("_ke_bookmark");return c||e||a}function b(a){return!w(a)&&!x(a)}function k(a){var c=v;return function(e){if(x(e))return o;if(e.nodeType==g.TEXT_NODE){if(d.trim(e.nodeValue).length)return v}else if(e.nodeType==g.ELEMENT_NODE&&(e=g.nodeName(e),!H[e]))if(!a&&!p.ie&&"br"==e&&!c)c=o;else return v;return o}}
function n(a,e){var b=a.startContainer,f=a.endContainer,C=a.startOffset,j=a.endOffset,d,l=v,i=v,w=void 0,k=a.document,P;0<e&&(w=k.createDocumentFragment());if(a.collapsed)return w;a.optimizeBookmark();f[0].nodeType==g.TEXT_NODE?(i=o,f=f._4e_splitText(j)):0<f[0].childNodes.length&&(j>=f[0].childNodes.length?(f=new c(f[0].appendChild(k.createTextNode(""))),P=o):f=new c(f[0].childNodes[j]));b[0].nodeType==g.TEXT_NODE?(l=o,b._4e_splitText(C)):C?C>=b[0].childNodes.length?(b=new c(b[0].appendChild(k.createTextNode(""))),
d=o):b=new c(b[0].childNodes[C].previousSibling):(d=new c(k.createTextNode("")),b.prepend(d),b=d,d=o);var J=b._4e_parents(),K=f._4e_parents();J.each(function(a,c){J[c]=a});K.each(function(a,c){K[c]=a});for(var E,M,k=0;k<J.length&&!(E=J[k],M=K[k],!E.equals(M));k++);for(var C=w,h,p,x=k;x<J.length;x++){h=J[x];j=0<e&&!h.equals(b)?C.appendChild(h.clone()[0]):null;h=h[0].nextSibling;p=K[x];for(var m=f[0],n=p&&p[0];h&&!(n==h||m==h);)p=h.nextSibling,2==e?C.appendChild(h.cloneNode(o)):(g._4e_remove(h),1==
e&&C.appendChild(h)),h=p;j&&(C=j)}for(C=w;k<K.length;k++){h=K[k];j=0<e&&!h.equals(f)?C.appendChild(h.clone()[0]):null;if(!J[k]||!h._4e_sameLevel(J[k]))for(h=h[0].previousSibling;h;)p=h.previousSibling,2==e?C.insertBefore(h.cloneNode(o),C.firstChild):(g._4e_remove(h),1==e&&C.insertBefore(h,C.firstChild)),h=p;j&&(C=j)}if(2==e){if(l&&(E=b[0],E.nodeType==g.TEXT_NODE&&E.nextSibling&&E.nextSibling.nodeType==g.TEXT_NODE&&(E.data+=E.nextSibling.data,E.parentNode.removeChild(E.nextSibling))),i)i=f[0],i.nodeType==
g.TEXT_NODE&&i.previousSibling&&i.previousSibling.nodeType==g.TEXT_NODE&&(i.previousSibling.data+=i.data,i.parentNode.removeChild(i))}else{if(E&&M&&(!b._4e_sameLevel(E)||!f._4e_sameLevel(M)))i=E._4e_index(),d&&E._4e_sameLevel(b)&&i--,a.setStart(E.parent(),i+1);a.collapse(o)}d&&b.remove();P&&f.remove();return w}function m(a){a.collapsed=a.startContainer&&a.endContainer&&a.startContainer[0]==a.endContainer[0]&&a.startOffset==a.endOffset}function u(a){this.endOffset=this.endContainer=this.startOffset=
this.startContainer=t;this.collapsed=o;this.document=a}h.RANGE={POSITION_AFTER_START:1,POSITION_BEFORE_END:2,POSITION_BEFORE_START:3,POSITION_AFTER_END:4,ENLARGE_ELEMENT:1,ENLARGE_BLOCK_CONTENTS:2,ENLARGE_LIST_ITEM_CONTENTS:3,START:1,END:2,SHRINK_ELEMENT:1,SHRINK_TEXT:2};var o=!0,v=!1,t=null,a=h.RANGE,e=h.POSITION,g=d.DOM,p=d.UA,f=h.XHTML_DTD,c=d.Node,j=c.all,l={area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},w=new s.whitespaces,x=new s.bookmark,y=s.whitespaces(o),A=s.bookmark(!1,
!0),H={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,"var":1};d.augment(u,{toString:function(){var a=[],c=this.startContainer[0],e=this.endContainer[0];a.push((c.id||c.nodeName)+":"+this.startOffset);a.push((e.id||e.nodeName)+":"+this.endOffset);return a.join("<br/>")},optimize:function(){var a=this.startContainer,c=this.startOffset;a[0].nodeType!=g.ELEMENT_NODE&&(c?c>=a[0].nodeValue.length&&
this.setStartAfter(a):this.setStartBefore(a));a=this.endContainer;c=this.endOffset;a[0].nodeType!=g.ELEMENT_NODE&&(c?c>=a[0].nodeValue.length&&this.setEndAfter(a):this.setEndBefore(a))},setStartAfter:function(a){this.setStart(a.parent(),a._4e_index()+1)},setStartBefore:function(a){this.setStart(a.parent(),a._4e_index())},setEndAfter:function(a){this.setEnd(a.parent(),a._4e_index()+1)},setEndBefore:function(a){this.setEnd(a.parent(),a._4e_index())},optimizeBookmark:function(){var a=this.startContainer,
c=this.endContainer;a&&"span"==a.nodeName()&&a.attr("_ke_bookmark")&&this.setStartBefore(a);c&&"span"==c.nodeName()&&c.attr("_ke_bookmark")&&this.setEndAfter(c)},setStart:function(a,c){a[0].nodeType==g.ELEMENT_NODE&&l[a.nodeName()]&&(a=a.parent(),c=a._4e_index());this.startContainer=a;this.startOffset=c;this.endContainer||(this.endContainer=a,this.endOffset=c);m(this)},setEnd:function(a,c){a[0].nodeType==g.ELEMENT_NODE&&l[a.nodeName()]&&(a=a.parent(),c=a._4e_index()+1);this.endContainer=a;this.endOffset=
c;this.startContainer||(this.startContainer=a,this.startOffset=c);m(this)},setStartAt:function(c,e){switch(e){case a.POSITION_AFTER_START:this.setStart(c,0);break;case a.POSITION_BEFORE_END:c[0].nodeType==g.TEXT_NODE?this.setStart(c,c[0].nodeValue.length):this.setStart(c,c[0].childNodes.length);break;case a.POSITION_BEFORE_START:this.setStartBefore(c);break;case a.POSITION_AFTER_END:this.setStartAfter(c)}m(this)},setEndAt:function(c,e){switch(e){case a.POSITION_AFTER_START:this.setEnd(c,0);break;
case a.POSITION_BEFORE_END:c[0].nodeType==g.TEXT_NODE?this.setEnd(c,c[0].nodeValue.length):this.setEnd(c,c[0].childNodes.length);break;case a.POSITION_BEFORE_START:this.setEndBefore(c);break;case a.POSITION_AFTER_END:this.setEndAfter(c)}m(this)},cloneContents:function(){return n(this,2)},deleteContents:function(){return n(this,0)},extractContents:function(){return n(this,1)},collapse:function(a){a?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,
this.startOffset=this.endOffset);this.collapsed=o},clone:function(){var a=new u(this.document);a.startContainer=this.startContainer;a.startOffset=this.startOffset;a.endContainer=this.endContainer;a.endOffset=this.endOffset;a.collapsed=this.collapsed;return a},getEnclosedNode:function(){var a=this.clone();a.optimize();if(a.startContainer[0].nodeType!=g.ELEMENT_NODE||a.endContainer[0].nodeType!=g.ELEMENT_NODE)return t;var c=new s(a);c.evaluator=function(a){return y(a)&&A(a)};a=c.next();c.reset();c=
c.previous();return a&&a.equals(c)?a:t},shrink:function(c,e){if(!this.collapsed){var c=c||a.SHRINK_TEXT,b=this.clone(),f=this.startContainer,j=this.endContainer,d=this.startOffset,l=this.endOffset,i=o,w,h,k=o;f&&f[0].nodeType==g.TEXT_NODE&&(d?d>=f[0].nodeValue.length?b.setStartAfter(f):(b.setStartBefore(f),i=v):b.setStartBefore(f));j&&j[0].nodeType==g.TEXT_NODE&&(l?l>=j[0].nodeValue.length?b.setEndAfter(j):(b.setEndAfter(j),k=v):b.setEndBefore(j));if(i||k)h=new s(b),h.evaluator=function(e){return e.nodeType==
(c==a.SHRINK_ELEMENT?g.ELEMENT_NODE:g.TEXT_NODE)},h.guard=function(e,b){if(c==a.SHRINK_ELEMENT&&e.nodeType==g.TEXT_NODE||b&&e==w)return v;!b&&e.nodeType==g.ELEMENT_NODE&&(w=e);return o};i&&(b=h[c==a.SHRINK_ELEMENT?"lastForward":"next"]())&&this.setStartAt(b,e?a.POSITION_AFTER_START:a.POSITION_BEFORE_START);k&&(h.reset(),(h=h[c==a.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(h,e?a.POSITION_BEFORE_END:a.POSITION_AFTER_END));return i||k}},createBookmark2:function(a){var e=this.startContainer,
b=this.endContainer,f=this.startOffset,j=this.endOffset,d,l;if(!e||!b)return{start:0,end:0};if(a){if(e[0].nodeType==g.ELEMENT_NODE&&(d=new c(e[0].childNodes[f]))&&d[0]&&d[0].nodeType==g.TEXT_NODE&&0<f&&d[0].previousSibling.nodeType==g.TEXT_NODE)e=d,f=0;for(;e[0].nodeType==g.TEXT_NODE&&(l=e.prev(void 0,1))&&l[0].nodeType==g.TEXT_NODE;)e=l,f+=l[0].nodeValue.length;if(!this.collapsed){if(b[0].nodeType==g.ELEMENT_NODE&&(d=new c(b[0].childNodes[j]))&&d[0]&&d[0].nodeType==g.TEXT_NODE&&0<j&&d[0].previousSibling.nodeType==
g.TEXT_NODE)b=d,j=0;for(;b[0].nodeType==g.TEXT_NODE&&(l=b.prev(void 0,1))&&l[0].nodeType==g.TEXT_NODE;)b=l,j+=l[0].nodeValue.length}}return{start:e._4e_address(a),end:this.collapsed?t:b._4e_address(a),startOffset:f,endOffset:j,normalized:a,is2:o}},createBookmark:function(e){var b,f,g,j,l=this.collapsed;b=new c("<span>",t,this.document);b.attr("_ke_bookmark",1);b.css("display","none");b.html("&nbsp;");e&&(g=d.guid("ke_bm_"),b.attr("id",g+"S"));l||(f=b.clone(),f.html("&nbsp;"),e&&f.attr("id",g+"E"),
j=this.clone(),j.collapse(),j.insertNode(f));j=this.clone();j.collapse(o);j.insertNode(b);f?(this.setStartAfter(b),this.setEndBefore(f)):this.moveToPosition(b,a.POSITION_AFTER_END);return{startNode:e?g+"S":b,endNode:e?g+"E":f,serializable:e,collapsed:l}},moveToPosition:function(a,c){this.setStartAt(a,c);this.collapse(o)},trim:function(a,c){var e=this.startContainer,b=this.startOffset,f=this.collapsed;if((!a||f)&&e[0]&&e[0].nodeType==g.TEXT_NODE){if(b)if(b>=e[0].nodeValue.length)b=e._4e_index()+1,
e=e.parent();else{var j=e._4e_splitText(b),b=e._4e_index()+1,e=e.parent();g.equals(this.startContainer,this.endContainer)?this.setEnd(j,this.endOffset-this.startOffset):g.equals(e,this.endContainer)&&(this.endOffset+=1)}else b=e._4e_index(),e=e.parent();this.setStart(e,b);if(f){this.collapse(o);return}}e=this.endContainer;b=this.endOffset;!c&&!f&&e[0]&&e[0].nodeType==g.TEXT_NODE&&(b?(b>=e[0].nodeValue.length||e._4e_splitText(b),b=e._4e_index()+1):b=e._4e_index(),e=e.parent(),this.setEnd(e,b))},insertNode:function(a){this.optimizeBookmark();
this.trim(v,o);var c=this.startContainer;c[0].insertBefore(a[0],c[0].childNodes[this.startOffset]||null);c[0]==this.endContainer[0]&&this.endOffset++;this.setStartBefore(a)},moveToBookmark:function(a){var c=j(this.document);if(a.is2){var e=c._4e_getByAddress(a.start,a.normalized),b=a.startOffset,c=a.end&&c._4e_getByAddress(a.end,a.normalized),a=a.endOffset;this.setStart(e,b);c?this.setEnd(c,a):this.collapse(o)}else e=(b=a.serializable)?d.one("#"+a.startNode,c):a.startNode,a=b?d.one("#"+a.endNode,
c):a.endNode,this.setStartBefore(e),e._4e_remove(),a&&a[0]?(this.setEndBefore(a),a._4e_remove()):this.collapse(o)},getCommonAncestor:function(a,e){var b=this.startContainer,f=this.endContainer,b=b[0]==f[0]?a&&b[0].nodeType==g.ELEMENT_NODE&&this.startOffset==this.endOffset-1?new c(b[0].childNodes[this.startOffset]):b:b._4e_commonAncestor(f);return e&&b[0].nodeType==g.TEXT_NODE?b.parent():b},enlarge:function(){function e(a,c,b,f){var d=a[c?"startContainer":"endContainer"],l,i=c?0:1,h=0,k=c?"previousSibling":
"nextSibling";l=a[c?"startOffset":"endOffset"];if(d[0].nodeType==g.TEXT_NODE){if(c){if(l)return}else if(l<d[0].nodeValue.length)return;l=d[0][k];d=d[0].parentNode}else l=d[0].childNodes[l+(c?-1:1)]||null,d=d[0];for(;d;){for(;l;)if(w(l)||x(l))l=l[k];else break;if(l){if(!h)a[c?"setStartAfter":"setEndBefore"](j(l));break}d=j(d);if("body"==d.nodeName())break;if(h||d.equals(f))b[i]=d,h=1;else a[c?"setStartBefore":"setEndAfter"](d);l=d[0][k];d=d[0].parentNode}}return function(b){switch(b){case a.ENLARGE_ELEMENT:if(this.collapsed)break;
var b=this.getCommonAncestor(),f=[];e(this,1,f,b);e(this,0,f,b);f[0]&&f[1]&&(b=f[0].contains(f[1])?f[1]:f[0],this.setStartBefore(b),this.setEndAfter(b));break;case a.ENLARGE_BLOCK_CONTENTS:case a.ENLARGE_LIST_ITEM_CONTENTS:var d=new u(this.document),f=new c(this.document.body);d.setStartAt(f,a.POSITION_AFTER_START);d.setEnd(this.startContainer,this.startOffset);var d=new s(d),l,i,h=s.blockBoundary(b==a.ENLARGE_LIST_ITEM_CONTENTS?{br:1}:t),k=function(a){var c=h(a);c||(l=j(a));return c},w=function(a){var c=
k(a);!c&&"br"==g.nodeName(a)&&(i=j(a));return c};d.guard=k;d=d.lastBackward();l=l||f;this.setStartAt(l,"br"!=l.nodeName()&&(!d&&this.checkStartOfBlock()||d&&l.contains(d))?a.POSITION_AFTER_START:a.POSITION_AFTER_END);d=this.clone();d.collapse();d.setEndAt(f,a.POSITION_BEFORE_END);d=new s(d);d.guard=b==a.ENLARGE_LIST_ITEM_CONTENTS?w:k;l=t;d=d.lastForward();l=l||f;this.setEndAt(l,!d&&this.checkEndOfBlock()||d&&l.contains(d)?a.POSITION_BEFORE_END:a.POSITION_BEFORE_START);i&&this.setEndAfter(i)}}}(),
checkStartOfBlock:function(){var c=this.startContainer,e=this.startOffset;if(e&&c[0].nodeType==g.TEXT_NODE&&d.trim(c[0].nodeValue.substring(0,e)).length)return v;this.trim();c=new q(this.startContainer);e=this.clone();e.collapse(o);e.setStartAt(c.block||c.blockLimit,a.POSITION_AFTER_START);c=new s(e);c.evaluator=k(o);return c.checkBackward()},checkEndOfBlock:function(){var c=this.endContainer,e=this.endOffset;if(c[0].nodeType==g.TEXT_NODE&&d.trim(c[0].nodeValue.substring(e)).length)return v;this.trim();
c=new q(this.endContainer);e=this.clone();e.collapse(v);e.setEndAt(c.block||c.blockLimit,a.POSITION_BEFORE_END);c=new s(e);c.evaluator=k(v);return c.checkForward()},checkBoundaryOfElement:function(c,e){var b=this.clone();b[e==a.START?"setStartAt":"setEndAt"](c,e==a.START?a.POSITION_AFTER_START:a.POSITION_BEFORE_END);b=new s(b);b.evaluator=i;return b[e==a.START?"checkBackward":"checkForward"]()},getBoundaryNodes:function(){var a=this.startContainer,c=this.endContainer,b=this.startOffset,f=this.endOffset,
d;if(a[0].nodeType==g.ELEMENT_NODE)if(d=a[0].childNodes.length,d>b)a=j(a[0].childNodes[b]);else if(0==d)a=a._4e_previousSourceNode();else{for(a=a[0];a.lastChild;)a=a.lastChild;a=j(a);a=a._4e_nextSourceNode()||a}if(c[0].nodeType==g.ELEMENT_NODE)if(d=c[0].childNodes.length,d>f)c=j(c[0].childNodes[f])._4e_previousSourceNode(o);else if(0==d)c=c._4e_previousSourceNode();else{for(c=c[0];c.lastChild;)c=c.lastChild;c=j(c)}a._4e_position(c)&e.POSITION_FOLLOWING&&(a=c);return{startNode:a,endNode:c}},fixBlock:function(c,
e){var b=this.createBookmark(),f=j(this.document.createElement(e));this.collapse(c);this.enlarge(a.ENLARGE_BLOCK_CONTENTS);f[0].appendChild(this.extractContents());f._4e_trim();p.ie||f._4e_appendBogus();this.insertNode(f);this.moveToBookmark(b);return f},splitBlock:function(c){var e=new q(this.startContainer),b=new q(this.endContainer),f=e.block,g=b.block,l=t;if(!e.blockLimit.equals(b.blockLimit))return t;"br"!=c&&(f||(f=this.fixBlock(o,c),g=(new q(this.endContainer)).block),g||(g=this.fixBlock(v,
c)));c=f&&this.checkStartOfBlock();e=g&&this.checkEndOfBlock();this.deleteContents();f&&f[0]==g[0]&&(e?(l=new q(this.startContainer),this.moveToPosition(g,a.POSITION_AFTER_END),g=t):c?(l=new q(this.startContainer),this.moveToPosition(f,a.POSITION_BEFORE_START),f=t):(g=this.splitElement(f),!p.ie&&!d.inArray(f.nodeName(),["ul","ol"])&&f._4e_appendBogus()));return{previousBlock:f,nextBlock:g,wasStartOfBlock:c,wasEndOfBlock:e,elementPath:l}},splitElement:function(c){if(!this.collapsed)return t;this.setEndAt(c,
a.POSITION_BEFORE_END);var e=this.extractContents(),b=c.clone(v);b[0].appendChild(e);b.insertAfter(c);this.moveToPosition(c,a.POSITION_AFTER_END);return b},moveToElementEditablePosition:function(c,e){for(var f=0;c;){if(c[0].nodeType==g.TEXT_NODE){this.moveToPosition(c,e?a.POSITION_AFTER_END:a.POSITION_BEFORE_START);f=1;break}c[0].nodeType==g.ELEMENT_NODE&&c._4e_isEditable()&&(this.moveToPosition(c,e?a.POSITION_BEFORE_END:a.POSITION_AFTER_START),f=1);var d=c,l=f,j=void 0;d[0].nodeType==g.ELEMENT_NODE&&
d._4e_isEditable()&&(j=d[e?"last":"first"](b,1));!l&&!j&&(j=d[e?"prev":"next"](b,1));c=j}return!!f},selectNodeContents:function(a){var c=a[0];this.setStart(a,0);this.setEnd(a,c.nodeType==g.TEXT_NODE?c.nodeValue.length:c.childNodes.length)},insertNodeByDtd:function(a){var c,e,b,d=a.nodeName();c=f.$block[d];this.deleteContents();if(c){for(c=this.getCommonAncestor(v,o);(e=f[c.nodeName()])&&(!e||!e[d]);){var g=c.parent();this.checkStartOfBlock()&&this.checkEndOfBlock()?(this.setStartBefore(c),this.collapse(o),
c.remove()):b=c;c=g}b&&this.splitElement(b)}this.insertNode(a)}});r.injectDom({_4e_breakParent:function(a,c){var c=j(c),a=j(a),e,b=new h.Range(a[0].ownerDocument);b.setStartAfter(a);b.setEndAfter(c);e=b.extractContents();b.insertNode(a.remove());a.after(e)}});return h.Range=u},{requires:["./base","./utils","./walker","./elementPath","./dom"]});
KISSY.add("editor/core/selection",function(d){function h(a){this.document=a;this._={cache:{}};if(o)try{var c=this.getNative().createRange();if(!c||c.item&&c.item(0).ownerDocument!=a||c.parentElement&&c.parentElement().ownerDocument!=a)this.isInvalid=q}catch(e){this.isInvalid=q}}function r(a){a=new h(a);return!a||a.isInvalid?i:a}var s=d.Editor;s.SELECTION={SELECTION_NONE:1,SELECTION_TEXT:2,SELECTION_ELEMENT:3};var q=!0,i=null,b=d.UA,k=d.DOM,n=d.Node,m=s.SELECTION,u=s.RANGE,o=b.ie,v=s.Walker,t=s.Range,
a={img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};d.augment(h,{getNative:!o?function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=k._getWin(this.document).getSelection())}:function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=this.document.selection)},getType:!o?function(){var e=this._.cache;if(e.type)return e.type;var c=m.SELECTION_TEXT,b=this.getNative();if(b){if(1==b.rangeCount){var b=
b.getRangeAt(0),d=b.startContainer;d==b.endContainer&&d.nodeType==k.ELEMENT_NODE&&1==Number(b.endOffset-b.startOffset)&&a[d.childNodes[b.startOffset].nodeName.toLowerCase()]&&(c=m.SELECTION_ELEMENT)}}else c=m.SELECTION_NONE;return e.type=c}:function(){var a=this._.cache;if(a.type)return a.type;var c=m.SELECTION_NONE;try{var e=this.getNative(),b=e.type;"Text"==b&&(c=m.SELECTION_TEXT);"Control"==b&&(c=m.SELECTION_ELEMENT);e.createRange().parentElement&&(c=m.SELECTION_TEXT)}catch(d){}return a.type=c},
getRanges:o?function(){var a=function(a,e){a=a.duplicate();a.collapse(e);for(var b=a.parentElement(),f=b.childNodes,d,g=0;g<f.length;g++){var h=f[g];if(h.nodeType==k.ELEMENT_NODE){d=a.duplicate();d.moveToElementText(h);var h=d.compareEndPoints("StartToStart",a),p=d.compareEndPoints("EndToStart",a);d.collapse();if(0<h)break;else{if(!h||1==p&&-1==h)return{container:b,offset:g};if(!p)return{container:b,offset:g+1}}d=i}}d||(d=a.duplicate(),d.moveToElementText(b),d.collapse(!1));d.setEndPoint("StartToStart",
a);d=(""+d.text).replace(/\r\n|\r/g,"\n").length;try{for(;0<d;)d-=f[--g].nodeValue.length}catch(m){d=0}return 0===d?{container:b,offset:g}:{container:f[g],offset:-d}};return function(c){var e=this._.cache;if(e.ranges&&!c)return e.ranges;var b=this.getNative(),c=b&&b.createRange(),d=this.getType();if(!b)return[];if(d==m.SELECTION_TEXT)return b=new t(this.document),d=a(c,q),b.setStart(new n(d.container),d.offset),d=a(c),b.setEnd(new n(d.container),d.offset),e.ranges=[b];if(d==m.SELECTION_ELEMENT){e=
e.ranges=[];for(d=0;d<c.length;d++){for(var g=c.item(d),i=g.parentNode,h=0,b=new t(this.document);h<i.childNodes.length&&i.childNodes[h]!=g;h++);b.setStart(new n(i),h);b.setEnd(new n(i),h+1);e.push(b)}return e}return e.ranges=[]}}():function(a){var c=this._.cache;if(c.ranges&&!a)return c.ranges;var a=[],e=this.getNative();if(!e)return[];for(var b=0;b<e.rangeCount;b++){var d=e.getRangeAt(b),g=new t(this.document);g.setStart(new n(d.startContainer),d.startOffset);g.setEnd(new n(d.endContainer),d.endOffset);
a.push(g)}return c.ranges=a},getStartElement:function(){var a=this._.cache;if(void 0!==a.startElement)return a.startElement;var c,e=this.getNative();switch(this.getType()){case m.SELECTION_ELEMENT:return this.getSelectedElement();case m.SELECTION_TEXT:var b=this.getRanges()[0];if(b&&!b.collapsed){for(b.optimize();q;)if(c=b.startContainer,b.startOffset==(c[0].nodeType===k.ELEMENT_NODE?c[0].childNodes.length:c[0].nodeValue.length)&&!c._4e_isBlockBoundary())b.setStartAfter(c);else break;c=b.startContainer;
if(c[0].nodeType!=k.ELEMENT_NODE)return c.parent();c=new n(c[0].childNodes[b.startOffset]);if(!c[0]||c[0].nodeType!=k.ELEMENT_NODE)return b.startContainer;for(b=c[0].firstChild;b&&b.nodeType==k.ELEMENT_NODE;)c=new n(b),b=b.firstChild;return c}if(o)b=e.createRange(),b.collapse(q),c=new n(b.parentElement());else{if((c=e.anchorNode)&&c.nodeType!=k.ELEMENT_NODE)c=c.parentNode;c&&(c=new n(c))}}return a.startElement=c},getSelectedElement:function(){var b,c=this._.cache;if(void 0!==c.selectedElement)return c.selectedElement;
o&&(b=this.getNative().createRange(),b=b.item&&b.item(0));var e;if(b)e=new n(b);else{b=this.getRanges()[0];for(var d,g=2;g&&(!(e=b.getEnclosedNode())||!(e[0].nodeType==k.ELEMENT_NODE&&a[e.nodeName()]&&(d=e)));g--)b.shrink(u.SHRINK_ELEMENT);e=d}return c.selectedElement=e},reset:function(){this._.cache={}},selectElement:function(a){var c,b=this.document;if(o)try{c=b.body.createControlRange(),c.addElement(a[0]),c.select()}catch(e){c=b.body.createTextRange(),c.moveToElementText(a[0]),c.select()}finally{}else c=
b.createRange(),c.selectNode(a[0]),a=this.getNative(),a.removeAllRanges(),a.addRange(c);this.reset()},selectRanges:function(a){if(o){if(1<a.length){var c=a[a.length-1];a[0].setEnd(c.endContainer,c.endOffset);a.length=1}a[0]&&a[0].select()}else{c=this.getNative();if(!c)return;c.removeAllRanges();for(var e=0;e<a.length;e++){var d=a[e],g=this.document.createRange(),i=d.startContainer;if(d.collapsed&&(b.gecko&&1.09>b.gecko||b.opera||b.webkit)&&i[0].nodeType==k.ELEMENT_NODE&&!i[0].childNodes.length)i[0].appendChild(this.document.createTextNode(b.webkit?
"\u200b":"")),d.startOffset++,d.endOffset++;g.setStart(i[0],d.startOffset);g.setEnd(d.endContainer[0],d.endOffset);c.addRange(g)}}this.reset()},createBookmarks2:function(a){for(var c=[],b=this.getRanges(),e=0;e<b.length;e++)c.push(b[e].createBookmark2(a));return c},createBookmarks:function(a,c){for(var b=[],e=this.document,g,c=c||this.getRanges(),i=c.length,h=0;h<i;h++){b.push(g=c[h].createBookmark(a,q));var p=(a=g.serializable)?d.one("#"+g.startNode,e):g.startNode;g=a?d.one("#"+g.endNode,e):g.endNode;
for(var m=h+1;m<i;m++){var n=c[m],o=n.startContainer,r=n.endContainer;k.equals(o,p.parent())&&n.startOffset++;k.equals(o,g.parent())&&n.startOffset++;k.equals(r,p.parent())&&n.endOffset++;k.equals(r,g.parent())&&n.endOffset++}}return b},selectBookmarks:function(a){for(var c=[],b=0;b<a.length;b++){var e=new t(this.document);e.moveToBookmark(a[b]);c.push(e)}this.selectRanges(c);return this},getCommonAncestor:function(){var a=this.getRanges();return a[0].startContainer._4e_commonAncestor(a[a.length-
1].endContainer)},scrollIntoView:function(){var a=this.getStartElement();a&&a.scrollIntoView(void 0,!1)},removeAllRanges:function(){var a=this.getNative();o?a&&a.clear():a&&a.removeAllRanges()}});var e={table:1,tbody:1,tr:1},g=v.whitespaces(q),p=/\ufeff|\u00a0/;t.prototype.select=t.prototype.select=!o?function(){var a=this.startContainer;this.collapsed&&a[0].nodeType==k.ELEMENT_NODE&&!a[0].childNodes.length&&a[0].appendChild(this.document.createTextNode(""));var c=this.document.createRange();c.setStart(a[0],
this.startOffset);try{c.setEnd(this.endContainer[0],this.endOffset)}catch(b){if(0<=b.toString().indexOf("NS_ERROR_ILLEGAL_VALUE"))this.collapse(q),c.setEnd(this.endContainer[0],this.endOffset);else throw b;}a=r(this.document).getNative();a.removeAllRanges();a.addRange(c)}:function(a){var c=this.collapsed,b,d;if(this.startContainer[0]===this.endContainer[0]&&1==this.endOffset-this.startOffset){var i=this.startContainer[0].childNodes[this.startOffset];if(i.nodeType==k.ELEMENT_NODE){(new h(this.document)).selectElement(new n(i));
return}}(this.startContainer[0].nodeType==k.ELEMENT_NODE&&this.startContainer.nodeName()in e||this.endContainer[0].nodeType==k.ELEMENT_NODE&&this.endContainer.nodeName()in e)&&this.shrink(u.SHRINK_ELEMENT,q);var m=this.createBookmark(),i=m.startNode,o;c||(o=m.endNode);m=this.document.body.createTextRange();m.moveToElementText(i[0]);m.moveStart("character",1);if(o)a=this.document.body.createTextRange(),a.moveToElementText(o[0]),m.setEndPoint("EndToEnd",a),m.moveEnd("character",-1);else{for(b=i[0].nextSibling;b&&
!g(b);)b=b.nextSibling;b=!(b&&b.nodeValue&&b.nodeValue.match(p))&&(a||!i[0].previousSibling||i[0].previousSibling&&"br"==k.nodeName(i[0].previousSibling));d=new n(this.document.createElement("span"));d.html("&#65279;");d.insertBefore(i);b&&k.insertBefore(this.document.createTextNode("\ufeff"),i[0]||i)}this.setStartBefore(i);i._4e_remove();if(c){if(b?(m.moveStart("character",-1),m.select(),this.document.selection.clear()):m.select(),d)this.moveToPosition(d,u.POSITION_BEFORE_START),d._4e_remove()}else this.setEndBefore(o),
o._4e_remove(),m.select()};h.getSelection=r;return s.Selection=h},{requires:["./base","./walker","./range","./dom"]});
KISSY.add("editor/core/selectionFix",function(d,h){function r(a){function b(a,c){var e=j.body.createTextRange();try{e.moveToPoint(a,c)}catch(d){e=n}return e}function d(){var a=j.selection.createRange();l&&!a.item&&0===a.compareEndPoints("StartToEnd",a)&&l.select();u.remove(j,"mouseup",d);u.remove(j,"mousemove",i);l=f=0}function i(a){if(a.button){if(a=b(a.pageX,a.pageY))0<a.compareEndPoints("StartToStart",l)?a.setEndPoint("StartToStart",l):a.setEndPoint("EndToEnd",l),a.select()}else d()}var f,c=a.get("window")[0],
j=a.get("document")[0],l;u.on(j,"mousedown contextmenu",function(a){var h=j.documentElement;if(a.target===h&&(f&&d(),!(h.scrollHeight>h.clientHeight)&&(f=1,l=b(a.pageX,a.pageY))))u.on(j,"mouseup",d),u.on(j,"mousemove",i),c.focus(),l.select()})}function s(a){function e(i){if(j){var f=a.getSelection(),l=f&&f.getType(),h=f&&d.selection;if(i&&h&&l==t.SELECTION_NONE&&!d.queryCommandEnabled("InsertImage"))setTimeout(function(){e(b)},50);else{var k;if(!h||!h.type||!("Control"!=h.type&&(k=h.createRange())&&
(k=k.parentElement())&&(k=k.nodeName)&&k.toLowerCase()in{input:1,textarea:1}))c=h&&f.getRanges()[0],a.checkSelectionChange()}}}var d=a.get("document")[0],i=new v(d.body),f=new v(d.documentElement);if(8>h.Utils.ieEngine)f.on("click",function(b){"html"===(new v(b.target)).nodeName()&&a.getSelection().getNative().createRange().select()});var c,j,l=b;f.on("mousedown",function(){l=k});f.on("mouseup",function(){l=b});i.on("focusin",function(a){if("body"==(new v(a.target)).nodeName()&&c){try{l&&c.select()}catch(b){}c=
n}});i.on("focus",function(){j=b;e()});i.on("beforedeactivate",function(a){a.relatedTarget||(j=k,l=b)});i.on("mousedown",function(){j=k});i.on("mouseup",function(){j=b;setTimeout(function(){e(b)},0)});i.on("keydown",function(){j=k});i.on("keyup",function(){j=b;setTimeout(function(){e()},0)})}function q(a){var b=a.get("document")[0];u.on(b,"mouseup keyup",function(){a.checkSelectionChange()})}function i(a){function e(a){var b=h.XHTML_DTD;return a._4e_isBlockBoundary()&&b.$empty[a.nodeName()]}function d(a){return f(a)&&
c(a)}var i=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;|(<\!--[\s\S]*?--\>))?\s*(:?<\/\1>)?(?=\s*$|<\/body>)/gi,f=h.Walker.whitespaces(b),c=h.Walker.bookmark(k,b),j=function(a){return f(a)&&8!=a.nodeType};a.on("selectionChange",function(c){var f=c.path,n=new v(a.get("document")[0].body),c=(c=c.selection)&&c.getRanges()[0],r=f.blockLimit;if(m.gecko){var q=f.block||f.blockLimit,s=q&&q.last(d);q&&q._4e_isBlockBoundary()&&(!s||!(1==s[0].nodeType&&s._4e_isBlockBoundary()))&&
"pre"!=q.nodeName()&&!q._4e_getBogus()&&q._4e_appendBogus()}if(c&&c.collapsed&&!f.block){if("body"==r.nodeName()){if((f=c.fixBlock(b,"p"))&&f[0]!=n[0].lastChild&&f._4e_outerHtml().match(i))if((r=f.next(j,1))&&r[0].nodeType==o.ELEMENT_NODE&&!e[r])c.moveToElementEditablePosition(r),f._4e_remove();else if((r=f.prev(j,1))&&r[0].nodeType==o.ELEMENT_NODE&&!e[r])c.moveToElementEditablePosition(r,r._4e_outerHtml().match(i)?k:b),f._4e_remove();c.select();a.notifySelectionChange()}f=a.get("document")[0];c=
new h.Range(f);c.moveToElementEditablePosition(n,b);"body"!==(new h.ElementPath(c.startContainer)).blockLimit.nodeName()&&(n=(new v(f.createElement("p"))).appendTo(n),m.ie||n._4e_appendBogus())}})}var b=!0,k=!1,n=null,m=d.UA,u=d.Event,o=d.DOM,v=d.Node,t=h.SELECTION;return{init:function(a){a.docReady(function(){m.ie?(r(a),s(a)):q(a)});i(a)}}},{requires:["./base","./selection"]});
KISSY.add("editor/core/styles",function(d,h){function r(a){return!y.attr(a,"_ke_bookmark")}function s(a,c){for(var b in a)a.hasOwnProperty(b)&&(d.isString(a[b])?a[b]=a[b].replace(Q,function(a,b){return c[b]}):s(a[b],c))}function q(a,c){c&&(a=d.clone(a),s(a,c));var b=this.element=this.element=(a.element||"*").toLowerCase();this.type=this.type="#text"==b||I[b]?A.STYLE_BLOCK:N[b]?A.STYLE_OBJECT:A.STYLE_INLINE;this._={definition:a}}function i(a,c){var b=c?this.removeFromRange:this.applyToRange;a.body.focus();
for(var e=new B(a),d=e.getRanges(),g=0;g<d.length;g++)b.call(this,d[g]);e.selectRanges(d)}function b(a,c,b){var e=a.element;"*"==e&&(e="span");c=new F(c.createElement(e));b&&b._4e_copyAttributes(c);b=a._.definition;a=b.attributes;b=q.getStyleText(b);if(a)for(var d in a)a.hasOwnProperty(d)&&c.attr(d,a[d]);b&&(c[0].style.cssText=b);return c}function k(a){var c=a.createBookmark(l),e=a.createIterator();e.enforceRealBlocks=l;e.enlargeBr=l;for(var d,g=a.document;d=e.getNextParagraph();){var f=b(this,g,
d),i=f,f="pre"==i.nodeName,h="pre"==d.nodeName,j=!f&&h;f&&!h?(h=d,j=h.html(),j=n(j,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,""),j=j.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,"$1"),j=j.replace(/([ \t\n\r]+|&nbsp;)/g," "),j=j.replace(/<br\b[^>]*>/gi,"\n"),C.ie?(h=h[0].ownerDocument.createElement("div"),h.appendChild(i[0]),i[0].outerHTML="<pre>"+j+"</pre>",i=new F(h.firstChild),i._4e_remove()):i.html(j)):j?i=u(m(d),i):d._4e_moveChildren(i);d[0].parentNode.replaceChild(i[0],d[0]);if(f&&(d=i,f=void 0,(f=d._4e_previousSourceNode(l,
y.ELEMENT_NODE))&&"pre"==f.nodeName()))i=n(f.html(),/\n$/,"")+"\n\n"+n(d.html(),/^\n/,""),C.ie?d[0].outerHTML="<pre>"+i+"</pre>":d.html(i),f._4e_remove()}a.moveToBookmark(c)}function n(a,c,b){var e="",d="",a=a.replace(/(^<span[^>]+_ke_bookmark.*?\/span>)|(<span[^>]+_ke_bookmark.*?\/span>$)/gi,function(a,c,b){c&&(e=c);b&&(d=b);return""});return e+a.replace(c,b)+d}function m(a){var c=[];n(a._4e_outerHtml(),/(\S\s*)\n(?:\s|(<span[^>]+_ck_bookmark.*?\/span>))*\n(?!$)/gi,function(a,c,b){return c+"</pre>"+
b+"<pre>"}).replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,function(a,b){c.push(b)});return c}function u(a,c){for(var b=c[0].ownerDocument.createDocumentFragment(),e=0;e<a.length;e++){var d=a[e],d=d.replace(/(\r\n|\r)/g,"\n"),d=n(d,/^[ \t]*\n/,""),d=n(d,/\n$/,""),d=n(d,/^[ \t]+|[ \t]+$/g,function(a,c){return 1==a.length?"&nbsp;":c?" "+Array(a.length).join("&nbsp;"):Array(a.length).join("&nbsp;")+" "}),d=d.replace(/\n/g,"<br>"),d=d.replace(/[ \t]{2,}/g,function(a){return Array(a.length).join("&nbsp;")+" "}),
g=c.clone();g.html(d);b.appendChild(g[0])}return b}function o(a){var c=a.document;if(a.collapsed)c=b(this,c,void 0),a.insertNode(c),a.moveToPosition(c,H.POSITION_BEFORE_END);else{var e=this.element,d=this._.definition,g,i=L[e];i||(g=l,i=L.span);var h=a.createBookmark();a.enlarge(H.ENLARGE_ELEMENT);a.trim();for(var j=a.createBookmark(),k=j.startNode,j=j.endNode,D=k,p;D&&D[0];){var m=w;if(y.equals(D,j))D=x,m=l;else{var n=D[0].nodeType,I=n==y.ELEMENT_NODE?D.nodeName():x;if(I&&D.attr("_ke_bookmark")){D=
D._4e_nextSourceNode(l);continue}if(!I||i[I]&&(D._4e_position(j)|z.POSITION_PRECEDING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_PRECEDING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED&&(!d.childRule||d.childRule(D))){var o=D.parent();if(o&&"a"==e&&o.nodeName()==e)n=b(this,c,void 0),o._4e_moveChildren(n),o[0].parentNode.replaceChild(n[0],o[0]),n._4e_mergeSiblings();else if(o&&o[0]&&((L[o.nodeName()]||L.span)[e]||g)&&(!d.parentRule||d.parentRule(o))){if(!p&&(!I||!L.$removeEmpty[I]||(D._4e_position(j)|
z.POSITION_PRECEDING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_PRECEDING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED))p=new G(c),p.setStartBefore(D);if(n==y.TEXT_NODE||n==y.ELEMENT_NODE&&!D[0].childNodes.length){o=D;for(n=null;(m=!o.next(r,1))&&(n=o.parent())&&i[n.nodeName()]&&(n._4e_position(k)|z.POSITION_FOLLOWING|z.POSITION_IDENTICAL|z.POSITION_IS_CONTAINED)==z.POSITION_FOLLOWING+z.POSITION_IDENTICAL+z.POSITION_IS_CONTAINED&&(!d.childRule||d.childRule(n));)o=n;p.setEndAfter(o)}}else m=
l}else m=l;D=D._4e_nextSourceNode()}if(m&&p&&!p.collapsed){for(var m=b(this,c,void 0),o=p.getCommonAncestor(),n={},I={},q,s=null,t;m&&o&&m[0]&&o[0];){if(o.nodeName()==e){for(q in d.attributes)if(d.attributes.hasOwnProperty(q)&&!I[q]&&(t=o.attr(s)))m.attr(q)==t?m.removeAttr(q):I[q]=1;for(s in d.styles)if(d.styles.hasOwnProperty(s)&&!n[s]&&(t=o.style(s)))m.style(s)==t?m.style(s,""):n[s]=1;if(!m._4e_hasAttributes()){m=x;break}}o=o.parent()}m?(m[0].appendChild(p.extractContents()),f(this,m),p.insertNode(m),
m._4e_mergeSiblings(),C.ie||m[0].normalize()):(m=new F(c.createElement("span")),m[0].appendChild(p.extractContents()),p.insertNode(m),f(this,m),m._4e_remove(!0));p=x}}k._4e_remove();j._4e_remove();a.moveToBookmark(h);a.shrink(H.SHRINK_TEXT)}}function v(a){a.enlarge(H.ENLARGE_ELEMENT);var b=a.createBookmark(),d=b.startNode;if(a.collapsed){for(var i=new D(d.parent()),f,j=0,h;j<i.elements.length&&(h=i.elements[j])&&!(h==i.block||h==i.blockLimit);j++)if(this.checkElementRemovable(h)){var k=a.checkBoundaryOfElement(h,
H.END),l=!k&&a.checkBoundaryOfElement(h,H.START);l||k?(f=h,f.match=l?"start":"end"):(h._4e_mergeSiblings(),h.nodeName()!=this.element?(k=e(this),c(h,k[h.nodeName()]||k["*"])):g(this,h))}if(f){h=d;for(j=0;;j++){k=i.elements[j];if(y.equals(k,f))break;else if(k.match)continue;else k=k.clone();k[0].appendChild(h[0]);h=k}h["start"==f.match?"insertBefore":"insertAfter"](f)}}else{var C=b.endNode,m=this,i=function(){for(var a=new D(d.parent()),c=new D(C.parent()),b=x,e=x,g=0;g<a.elements.length;g++){var f=
a.elements[g];if(f==a.block||f==a.blockLimit)break;m.checkElementRemovable(f)&&(b=f)}for(g=0;g<c.elements.length;g++){f=c.elements[g];if(f==c.block||f==c.blockLimit)break;m.checkElementRemovable(f)&&(e=f)}e&&C._4e_breakParent(e);b&&d._4e_breakParent(b)};i();for(f=new F(d[0].nextSibling);f[0]!==C[0];){j=f._4e_nextSourceNode();if(f[0]&&f[0].nodeType==y.ELEMENT_NODE&&this.checkElementRemovable(f)&&(f.nodeName()==this.element?g(this,f):(h=e(this),c(f,h[f.nodeName()]||h["*"])),j[0].nodeType==y.ELEMENT_NODE&&
j.contains(d)))i(),j=new F(d[0].nextSibling);f=j}}a.moveToBookmark(b)}function t(a){var c={};(""+a).replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(a,b,e){c[b]=e});return c}function a(a,c){var b="";c!==w?(b=document.createElement("span"),b.style.cssText=a,b=b.style.cssText||""):b=a;return b.replace(/\s*([;:])\s*/,"$1").replace(/([^\s;])$/,"$1;").replace(/,\s+/g,",").toLowerCase()}function e(a){if(a._.overrides)return a._.overrides;var c=a._.overrides={},b=a._.definition.overrides;
if(b){d.isArray(b)||(b=[b]);for(var e=0;e<b.length;e++){var g=b[e],f,i,h;"string"==typeof g?f=g.toLowerCase():(f=g.element?g.element.toLowerCase():a.element,i=g.attributes,h=g.styles);g=c[f]||(c[f]={});if(i){f=g.attributes=g.attributes||[];for(var j in i)i.hasOwnProperty(j)&&f.push([j.toLowerCase(),i[j]])}if(h){var g=g.styles=g.styles||[],k;for(k in h)h.hasOwnProperty(k)&&g.push([k.toLowerCase(),h[k]])}}}return c}function g(a,c){var b=a._.definition,g=e(a),f=d.merge(b.attributes,(g[c.nodeName()]||
g["*"]||{}).attributes),b=d.merge(b.styles,(g[c.nodeName()]||g["*"]||{}).styles),g=d.isEmptyObject(f)&&d.isEmptyObject(b),i;for(i in f)if(f.hasOwnProperty(i)&&!(("class"==i||a._.definition.fullMatch)&&c.attr(i)!=p(i,f[i])))g=g||!!c.hasAttr(i),c.removeAttr(i);for(var h in b)b.hasOwnProperty(h)&&!(a._.definition.fullMatch&&c.style(h)!=p(h,b[h],l))&&(g=g||!!c.style(h),c.style(h,""));j(c)}function p(a,c,b){var e=new F("<span>");e[b?"style":"attr"](a,c);return e[b?"style":"attr"](a)}function f(a,b){for(var d=
e(a),f=b.all(a.element),i=f.length;0<=--i;)g(a,new F(f[i]));for(var h in d)if(d.hasOwnProperty(h)&&h!=a.element){f=b.all(h);for(i=f.length-1;0<=i;i--){var j=new F(f[i]);c(j,d[h])}}}function c(a,c){var b,e=c&&c.attributes;if(e)for(b=0;b<e.length;b++){var d=e[b][0],g;if(g=a.attr(d)){var f=e[b][1];(f===x||f.test&&f.test(g)||"string"==typeof f&&g==f)&&a[0].removeAttribute(d)}}if(e=c&&c.styles)for(b=0;b<e.length;b++)if(d=e[b][0],f=a.css(d)){var i=e[b][1];(i===x||i.test&&i.test(g)||"string"==typeof i&&
f==i)&&a.css(d,"")}j(a)}function j(a){if(!a._4e_hasAttributes()){var b=a[0].firstChild,c=a[0].lastChild;a._4e_remove(l);b&&(b.nodeType==y.ELEMENT_NODE&&y._4e_mergeSiblings(b),c&&b!=c&&c.nodeType==y.ELEMENT_NODE&&y._4e_mergeSiblings(c))}}var l=!0,w=!1,x=null,y=d.DOM,A={STYLE_BLOCK:1,STYLE_INLINE:2,STYLE_OBJECT:3},H=h.RANGE,B=h.Selection,z=h.POSITION,G=h.Range,F=d.Node,C=d.UA,D=h.ElementPath,I={address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1},L=h.XHTML_DTD,N={embed:1,hr:1,img:1,li:1,object:1,
ol:1,table:1,td:1,tr:1,th:1,ul:1,dl:1,dt:1,dd:1,form:1},O=/\s*(?:;\s*|$)/g,Q=/#\((.+?)\)/g;h.STYLE=A;q.prototype={apply:function(a){i.call(this,a,w)},remove:function(a){i.call(this,a,l)},applyToRange:function(a){return(this.applyToRange=this.type==A.STYLE_INLINE?o:this.type==A.STYLE_BLOCK?k:x).call(this,a)},removeFromRange:function(a){return(this.removeFromRange=this.type==A.STYLE_INLINE?v:x).call(this,a)},checkElementRemovable:function(b,c){if(!b)return w;var d=this._.definition,g;if(b.nodeName()==
this.element){if(!c&&!b._4e_hasAttributes())return l;var f=d._AC;if(f)d=f;else{var f={},i=0,h=d.attributes;if(h)for(var j in h)h.hasOwnProperty(j)&&(i++,f[j]=h[j]);if(h=q.getStyleText(d))f.style||i++,f.style=h;f._length=i;d=d._AC=f}if(d._length){for(var k in d)if("_length"!=k&&d.hasOwnProperty(k)){i=b.attr(k)||"";if("style"==k)a:{f=d[k];i=a(i,w);"string"==typeof f&&(f=t(f));"string"==typeof i&&(i=t(i));h=void 0;for(h in f)if(f.hasOwnProperty(h)&&!(h in i&&(i[h]==f[h]||"inherit"==f[h]||"inherit"==
i[h]))){f=w;break a}f=l}else f=d[k]==i;if(f){if(!c)return l}else if(c)return w}if(c)return l}else return l}k=e(this);if(k=k[b.nodeName()]||k["*"]){if(!(d=k.attributes)&&!(g=k.styles))return l;if(d)for(f=0;f<d.length;f++)if(k=d[f][0],k=b.attr(k))if(i=d[f][1],i===x||"string"==typeof i&&k==i||i.test&&i.test(k))return l;if(g)for(f=0;f<g.length;f++)if(k=b.css(g[f][0]))if(d=g[f][1],d===x||"string"==typeof d&&k==d||d.test&&d.test(k))return l}return w},checkActive:function(a){switch(this.type){case A.STYLE_BLOCK:return this.checkElementRemovable(a.block||
a.blockLimit,l);case A.STYLE_OBJECT:case A.STYLE_INLINE:for(var b=a.elements,c=0,e;c<b.length;c++)if(e=b[c],!(this.type==A.STYLE_INLINE&&(y.equals(e,a.block)||y.equals(e,a.blockLimit))))if((this.type!=A.STYLE_OBJECT||e.nodeName()in N)&&this.checkElementRemovable(e,l))return l}return w}};q.getStyleText=function(b){var c=b._ST;if(c)return c;var c=b.styles,e=b.attributes&&b.attributes.style||"",d="";e.length&&(e=e.replace(O,";"));for(var f in c)if(c.hasOwnProperty(f)){var g=c[f],i=(f+":"+g).replace(O,
";");"inherit"==g?d+=i:e+=i}e.length&&(e=a(e));return b._ST=e+d};return h.Style=q},{requires:["./base","./range","./selection","./domIterator","./elementPath"]});
KISSY.add("editor/core/utils",function(d){var h=d.Node,r=d.DOM,s=d.UA,q={debugUrl:function(i){var b=d.Config;b.debug||(i=i.replace(/\.(js|css)/i,"-min.$1"));-1==i.indexOf("?t")&&(i=-1!=i.indexOf("?")?i+"&":i+"?",i+="t="+encodeURIComponent(b.tag));return b.base+"editor/"+i},lazyRun:function(d,b,h){var n=d[b],m=d[h];d[b]=function(){n.apply(this,arguments);d[b]=d[h];return m.apply(this,arguments)}},getXY:function(d,b){var h=d.left,n=d.top,m=b.get("window")[0],h=h-r.scrollLeft(m),n=n-r.scrollTop(m),m=
b.get("iframe").offset(),h=h+m.left,n=n+m.top;return{left:h,top:n}},tryThese:function(d){for(var b,h=0,n=arguments.length;h<n;h++){var m=arguments[h];try{b=m();break}catch(q){}}return b},arrayCompare:function(d,b){if(!d&&!b)return!0;if(!d||!b||d.length!=b.length)return!1;for(var h=0;h<d.length;h++)if(d[h]!==b[h])return!1;return!0},clearAllMarkers:function(d){for(var b in d)d.hasOwnProperty(b)&&d[b]._4e_clearMarkers(d,!0,void 0)},ltrim:function(d){return d.replace(/^\s+/,"")},rtrim:function(d){return d.replace(/\s+$/,
"")},isNumber:function(i){return/^\d+(.\d+)?$/.test(d.trim(i))},verifyInputs:function(i){for(var b=0;b<i.length;b++){var k=new h(i[b]),n=d.trim(q.valInput(k)),m=k.attr("data-verify"),k=k.attr("data-warning");if(m&&!RegExp(m).test(n))return alert(k),!1}return!0},sourceDisable:function(d,b){d.on("sourceMode",b.disable,b);d.on("wysiwygMode",b.enable,b)},resetInput:function(d){var b=d.attr("placeholder");b&&s.ie?(d.addClass("ks-editor-input-tip"),d.val(b)):s.ie||d.val("")},valInput:function(d,b){if(void 0===
b)return d.hasClass("ks-editor-input-tip")?"":d.val();d.removeClass("ks-editor-input-tip");d.val(b)},placeholder:function(i,b){i.attr("placeholder",b);s.ie&&(i.on("blur",function(){d.trim(i.val())||(i.addClass("ks-editor-input-tip"),i.val(b))}),i.on("focus",function(){i.removeClass("ks-editor-input-tip");d.trim(i.val())==b&&i.val("")}))},htmlEncode:function(d){return!d?d:(""+d).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},normParams:function(i){var i=d.clone(i),
b;for(b in i)if(i.hasOwnProperty(b)){var h=i[b];d.isFunction(h)&&(i[b]=h())}return i},map:function(d,b){for(var h=0;h<d.length;h++)d[h]=b(d[h]);return d},ieEngine:document.documentMode||s.ie,preventFocus:function(d){s.ie?d.unselectable(void 0):d.attr("onmousedown","return false;")},injectDom:function(i){d.mix(r,i);for(var b in i)i.hasOwnProperty(b)&&function(b){h.prototype[b]=function(){var n=[].slice.call(arguments,0);n.unshift(this[0]);return(n=i[b].apply(null,n))&&(n.nodeType||d.isWindow(n))?new h(n):
d.isArray(n)&&(n.__IS_NODELIST||n[0]&&n[0].nodeType)?new h(n):n}}(b)},addRes:function(){var i=this.__res=this.__res||[];i.push.apply(i,d.makeArray(arguments))},destroyRes:function(){for(var i=this.__res||[],b=0;b<i.length;b++){var h=i[b];d.isFunction(h)?h():h.destroy?h.destroy():h.remove&&h.remove()}this.__res=[]},getQueryCmd:function(d){return"query"+("-"+d).replace(/-(\w)/g,function(b,d){return d.toUpperCase()})+"Value"}};return d.Editor.Utils=q},{requires:["./base"]});
KISSY.add("editor/core/walker",function(d,h){function r(a,e){if(this._.end)return k;var d,c=this.range,h,l=this.guard,n=this.type,q=a?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start&&(this._.start=1,c.trim(),c.collapsed))return this.end(),k;if(!a&&!this._.guardLTR){var r=c.endContainer[0],s=r.childNodes[c.endOffset];this._.guardLTR=function(a,b){return b&&(r==a||"body"==m.nodeName(a))?!1:a!=s}}if(a&&!this._.guardRTL){var t=c.startContainer[0],u=0<c.startOffset&&t.childNodes[c.startOffset-
1]||null;this._.guardRTL=function(a,b){return b&&(t==a||"body"==m.nodeName(a))?!1:a!=u}}var v=a?this._.guardRTL:this._.guardLTR;h=l?function(a,c){return v(a,c)===b?b:l(a,c)}:v;this.current?d=this.current[q](b,n,h):a?(d=c.endContainer,0<c.endOffset?(d=new o(d[0].childNodes[c.endOffset-1]),h(d[0])===b&&(d=k)):d=h(d,i)===b?k:d._4e_previousSourceNode(i,n,h,void 0)):(d=c.startContainer,d=new o(d[0].childNodes[c.startOffset]),d.length?h(d[0])===b&&(d=k):d=h(c.startContainer,i)===b?k:c.startContainer._4e_nextSourceNode(i,
n,h,void 0));for(;d&&!this._.end;){this.current=d;if(!this.evaluator||this.evaluator(d[0])!==b){if(!e)return d}else if(e&&this.evaluator)return b;d=d[q](b,n,h)}this.end();return this.current=k}function s(a){for(var b,d=k;b=r.call(this,a);)d=b;return d}function q(a){this.range=a;this.guard=this.evaluator=k;this._={}}var i=!0,b=!1,k=null,n=d.UA,m=d.DOM,u=h.XHTML_DTD,o=d.Node;d.augment(q,{end:function(){this._.end=1},next:function(){return r.call(this)},previous:function(){return r.call(this,i)},checkForward:function(){return r.call(this,
b,i)!==b},checkBackward:function(){return r.call(this,i,i)!==b},lastForward:function(){return s.call(this)},lastBackward:function(){return s.call(this,i)},reset:function(){delete this.current;this._={}},_iterator:r});d.mix(q,{blockBoundary:function(a){return function(b){return!(b.nodeType==m.ELEMENT_NODE&&m._4e_isBlockBoundary(b,a))}},bookmark:function(a,b){function d(a){return"span"==m.nodeName(a)&&m.attr(a,"_ke_bookmark")}return function(c){var e,h;e=c.nodeType==m.TEXT_NODE&&(h=c.parentNode)&&d(h);
e=a?e:e||d(c);return!!(b^e)}},whitespaces:function(a){return function(b){b=b.nodeType==m.TEXT_NODE&&!d.trim(b.nodeValue);return!!(a^b)}},invisible:function(a){var b=q.whitespaces();return function(d){d=b(d)||d.nodeType==m.ELEMENT_NODE&&!d.offsetHeight;return!!(a^d)}}});var v=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,t=q.whitespaces(),a=q.bookmark(),e=function(b){var d=m.nodeName(b);return a(b)||t(b)||1==b.nodeType&&d in u.$inline&&!(d in u.$empty)};h.Utils.injectDom({_4e_getBogus:function(a){a=new o(a);do a=
a._4e_previousSourceNode();while(a&&e(a[0]));return a&&(!n.ie?"br"==a.nodeName():3==a[0].nodeType&&v.test(a.text()))?a[0]:!1}});return h.Walker=q},{requires:["./base","./utils","./dom"]});KISSY.add("editor/core/zIndexManager",function(d){var h=d.Editor,d=h.zIndexManager={BUBBLE_VIEW:1100,POPUP_MENU:1200,STORE_FLASH_SHOW:99999,MAXIMIZE:900,OVERLAY:9999,LOADING:11E3,LOADING_CANCEL:12E3,SELECT:1200};h.baseZIndex=function(d){return(h.Config.baseZIndex||1E4)+d};return d},{requires:["./base"]});
KISSY.add("editor",function(d,h,r,s,q,i,b,k,n,m,u){function o(a,b){var d=a.body;H(function(){a.designMode="on";setTimeout(function(){a.designMode="off";d.focus();arguments.callee.retry||(arguments.callee.retry=g)},50)},function(){a.designMode="off";x.attr(d,"contentEditable",c);x.attr(d,"contentEditable",g);!b&&o(a,1)})}function v(a){a.get("iframe");var b=a.get("textarea")[0],e=a.get("window")[0],f=a.get("document")[0];l.webkit&&(A.on(f,"click",function(a){var b=new y(a.target);d.inArray(b.nodeName(),
["input","select"])&&a.preventDefault()}),A.on(f,"mouseup",function(a){var b=new y(a.target);d.inArray(b.nodeName(),["input","textarea"])&&a.preventDefault()}));if(l.gecko||w||l.opera){var g;g=(new y('<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>')).insertAfter(b);g.on("focus",function(){a.focus()});a.activateGecko=function(){l.gecko&&a.__iframeFocus&&g[0].focus()};a.on("destroy",function(){g.detach();g.remove()})}A.on(e,"focus",function(){l.gecko?o(f,c):l.opera&&
f.body.focus();a.notifySelectionChange()});if(l.gecko)A.on(f,"mousedown",function(){a.__iframeFocus||o(f,c)});if(w&&(A.on(f,"keydown",function(b){if(b.keyCode in{8:1,46:1}){var c=a.getSelection(),d=c.getSelectedElement();if(d){a.execCommand("save");var e=c.getRanges()[0].createBookmark();d.remove();c.selectBookmarks([e]);a.execCommand("save");b.preventDefault()}}}),"CSS1Compat"==f.compatMode)){var h={33:1,34:1};A.on(f,"keydown",function(b){b.keyCode in h&&setTimeout(function(){a.getSelection().scrollIntoView()},
0)})}if(l.webkit)A.on(f,"mousedown",function(b){b=new y(b.target);d.inArray(b.nodeName(),["img","hr","input","textarea","select"])&&a.getSelection().selectElement(b)});if(l.gecko)A.on(f,"dragstart",function(a){var b=new y(a.target);b.nodeName()==="img"&&/ke_/.test(b[0].className)&&a.preventDefault()});s.add(a)}function t(a,b,c,e){var f="",g,h=r.debugUrl("theme/editor-iframe.css");for(g=0;g<c.length;g++)f+=d.substitute('<link href="{href}" rel="stylesheet" />',{href:c[g]});return d.substitute(B,{doctype:8===
j.documentMode?'<meta http-equiv="X-UA-Compatible" content="IE=7" />':"",title:"${title}",href:h,style:b,data:e||"&nbsp;",script:a?'<script id="ke_active_script">'+(x.isCustomDomain()?'document.domain="'+j.domain+'";':"")+'parent.KISSY.Editor._initIFrame("'+a+'");<\/script>':""})}function a(a,b){function c(){h=g.document;a.__set("document",new y(h));a.__set("window",new y(g));d.detach();h.open("text/html","replace");h.write(e);h.close()}var d=a.get("iframe"),e=t(a._UUID,a.get("customStyle"),a.get("customLink"),
b),f=d[0],g=f.contentWindow,h;d.__loaded=1;try{h=g.document}catch(i){if(f.src=f.src,7>w){setTimeout(c,10);return}}c()}function e(b,c){var e=x.getEmptyIframeSrc()||"";e&&(e=' src="'+e+'" ');var e=new y(d.substitute(z,{iframeSrc:e})),f=b.get("textarea");f.hasAttr("tabindex")&&e.attr("tabIndex",l.webkit?-1:f.attr("tabIndex"));f.parent().prepend(e);b.set("iframe",e);b.__docReady=0;if(l.gecko&&!e.__loaded)e.on("load",function(){a(b,c)},b);else a(b,c)}var g=!0,p=p,f=d.all,c=!1,j=document,l=d.UA,w=l.ie,
x=d.DOM,y=d.Node,A=d.Event,H=r.tryThese,B="<!doctype html><html><head>{doctype}<title>{title}</title><link href='{href}' rel='stylesheet' /><style>{style}</style>{links}</head><body class='ks-editor'>{data}{script}</body></html>",z='<iframe style="width:100%;height:100%;border:none;"  frameborder="0"  title="kissy-editor"  allowTransparency="true"  {iframeSrc} ></iframe>';d.mix(h,{SOURCE_MODE:0,WYSIWYG_MODE:1});var G=h.WYSIWYG_MODE;d.augment(h,{createDom:function(){var a,b=this.get("textarea"),c;
b||this.set("textarea",b=f("<textarea class='ks-editor-textarea'></textarea>"));c=this.get("el");c.html('<div class="ks-editor-tools"></div><div class="ks-editor-textarea-wrap"></div><div class=\'ks-editor-status\'></div>');a=c.one(".ks-editor-textarea-wrap");this._UUID=d.guid();this.set({toolBarEl:c.one(".ks-editor-tools"),statusBarEl:c.one(".ks-editor-status")},{silent:1});b.css("width","100%");b.css("display","none");a.append(b);s.register(this)},renderUI:function(){k.init(this);n.init(this);m.init(this);
u.init(this)},bindUI:function(){function a(){b.detach("docReady",a);if(b.get("focused"))b.focus();else{var c=b.getSelection();c&&c.removeAllRanges()}}var b=this,c,d=b.get("prefixCls"),e=b.get("textarea");if(b.get("attachForm")&&(c=e[0].form))x.on(c,"submit",b.sync,b),b.on("destroy",function(){x.detach(c,"submit",b.sync,b)});b.on("docReady",a);b.on("blur",function(){b.get("el").removeClass(d+"editor-focused")});b.on("focus",function(){b.get("el").addClass(d+"editor-focused")})},_uiSetHeight:function(a){var b=
this.get("textarea"),c=this.get("toolBarEl"),d=this.get("statusBarEl"),a=parseInt(a,10),a=a-((c&&c.outerHeight()||0)+(d&&d.outerHeight()||0));b.parent().css("height",a);b.css("height",a)},_uiSetMode:function(a){var b=this,c,d=b.get("rendered"),e=b.get("iframe"),f=b.get("textarea");a==G?(d&&b.execCommand("save"),b.on("docReady",c=function(){d&&b.execCommand("save");b.detach("docReady",c)}),b._setData(f.val()),b.fire("wysiwygMode")):(f.val(b._getData(1,G)),f.show(),e.hide(),b.fire("sourceMode"))},_uiSetFocused:function(a){a&&
this.__docReady&&this.focus()},destructor:function(){var a=this.get("document")[0],b=this.get("window");this.sync();s.remove(this);A.remove([a,a.documentElement,a.body,b[0]]);d.each(this.__controls,function(a){a.destroy&&a.destroy()});this.__commands={};this.__controls={}},getControl:function(a){return this.__controls[a]},getControls:function(){return this.__controls},addControl:function(a,b){this.__controls[a]=b},showDialog:function(a,b){var a=a+"/dialog",c=this.__controls[a];c.show(b);this.fire("dialogShow",
{dialog:c.dialog,pluginDialog:c,dialogName:a})},addCommand:function(a,b){this.__commands[a]=b},hasCommand:function(a){return this.__commands[a]},execCommand:function(a){var b=this.__commands[a],c=d.makeArray(arguments);c.shift();c.unshift(this);if(b)return b.exec.apply(b,c)},queryCommandValue:function(a){return this.execCommand(r.getQueryCmd(a))},_getData:function(a,b){var c=this.htmlDataProcessor,e;b==p&&(b=this.get("mode"));e=b==G?this.get("document")[0].body.innerHTML:c.toDataFormat(this.get("textarea").val());
e=a?c.toHtml(e):c.toServer(e);e=d.trim(e);/^(?:<(p)>)?(?:(?:&nbsp;)|\s)*(?:<\/\1>)?$/.test(e)&&(e="");return e},_setData:function(a){var b,c=a;if(this.get("mode")!=G)this.get("textarea").val(a);else{if(b=this.htmlDataProcessor)c=b.toDataFormat(a);if(this.get("iframe")){a=this.get("iframe");b=this.get("window")[0];var d=this.get("document")[0];A.remove([d,d.documentElement,d.body,b]);a.remove()}e(this,c)}},sync:function(){this.get("textarea").val(this.get("data"))},getDocHtml:function(){return t(0,
this.get("customStyle"),this.get("customLink"),this.get("formatData"))},getSelection:function(){return h.Selection.getSelection(this.get("document")[0])},focus:function(){var a=this.get("document")[0],b=this.get("window")[0];l.ie||b&&b.parent&&b.parent.focus();b&&b.focus();try{a.body.focus()}catch(c){}this.notifySelectionChange()},blur:function(){this.get("window")[0].blur();this.get("document")[0].body.blur()},addCustomStyle:function(a,b){var c=this.get("customStyle")||"",c=c+("\n"+a);this.set("customStyle",
c);x.addStyleSheet(this.get("window"),c,b)},removeCustomStyle:function(a){x.remove(x.get("#"+a,this.get("window")[0]))},addCustomLink:function(a){var b=this.get("customLink")||[],c=this.get("document")[0];b.push(a);this.set("customLink",b);b=c.createElement("link");b.rel="stylesheet";c.getElementsByTagName("head")[0].appendChild(b);b.href=a},removeCustomLink:function(a){for(var b=this.get("document")[0],b=x.query("link",b),c=0;c<b.length;c++)x.attr(b[c],"href")==a&&x.remove(b[c]);b=this.get("customLink")||
[];a=d.indexOf(a,b);-1!=a&&b.splice(a,1)},docReady:function(a){this.on("docReady",a);this.__docReady&&a.call(this)},checkSelectionChange:function(){var a=this;a.__checkSelectionChangeId&&clearTimeout(a.__checkSelectionChangeId);a.__checkSelectionChangeId=setTimeout(function(){var b=a.getSelection();if(b&&!b.isInvalid){var c=b.getStartElement(),d=new h.ElementPath(c);if(!a.__previousPath||!a.__previousPath.compare(d))a.__previousPath=d,a.fire("selectionChange",{selection:b,path:d,element:c})}},100)},
notifySelectionChange:function(){this.__previousPath=null;this.checkSelectionChange()},insertElement:function(a){if(this.get("mode")===G){this.focus();var b,c=a.nodeName(),d=h.XHTML_DTD,e=d.$block[c],f=h.RANGE,i=(c=this.getSelection())&&c.getRanges(),j,k,l;if(i&&0!=i.length){this.execCommand("save");for(k=i.length-1;0<=k;k--)j=i[k],b=!k&&a||a.clone(g),j.insertNodeByDtd(b),l||(l=b);if(l)return j.moveToPosition(l,f.POSITION_AFTER_END),e&&(a=h.Walker.whitespaces(!0),(a=(l=l.next(a,1))&&l[0].nodeType==
x.ELEMENT_NODE&&l.nodeName())&&d.$block[a]&&d[a]["#text"]&&j.moveToElementEditablePosition(l)),c.selectRanges([j]),this.focus(),b&&1==b[0].nodeType&&b.scrollIntoView(p,!1),F.call(this),b}}},insertHtml:function(a,b){var d=this,e,f=d.get("document")[0];if(d.get("mode")===G){if(e=d.htmlDataProcessor)a=e.toDataFormat(a,b);d.focus();d.execCommand("save");if(w){e=f.selection;"Control"==e.type&&e.clear();try{e.createRange().pasteHTML(a)}catch(g){}}else try{f.execCommand("inserthtml",c,a)}catch(i){setTimeout(function(){if(0==
d.getSelection().getRanges().length){var b=new h.Range(f),e=x.first(f.body,function(a){return 1==a.nodeType&&"br"!=x.nodeName(a)});e||(e=new y(f.createElement("p")),e._4e_appendBogus(p),f.body.appendChild(e[0]));b.setStartAt(e,h.RANGE.POSITION_AFTER_START);b.select()}f.execCommand("inserthtml",c,a)},50)}setTimeout(function(){d.getSelection().scrollIntoView()},50);F.call(d)}}});h._initIFrame=function(a){var b=s.getInstance(a),d=b.get("document")[0],a=d.getElementById("ke_active_script");x.remove(a);
v(b);var e=d.body;w?(e.hideFocus=g,e.disabled=g,e.contentEditable=g,e.removeAttribute("disabled")):setTimeout(function(){l.gecko||l.opera?e.contentEditable=g:l.webkit?e.parentNode.contentEditable=g:d.designMode="on"},0);if(l.gecko||l.opera){var f=d.documentElement;A.on(f,"mousedown",function(a){if(a.target==f){l.gecko&&o(d,c);b.activateGecko()}})}setTimeout(function(){w&&setTimeout(function(){if(d){e.runtimeStyle.marginBottom="0px";e.runtimeStyle.marginBottom=""}},1E3)},0);setTimeout(function(){b.__docReady=
1;b.fire("docReady");var a=b.get("disableObjectResizing"),f=b.get("disableInlineTableEditing");if(a||f)try{d.execCommand("enableObjectResizing",c,!a);d.execCommand("enableInlineTableEditing",c,!f)}catch(g){A.on(e,w?"resizestart":"resize",function(b){var c=new y(b.target);(a||c.nodeName()==="table"&&f)&&b.preventDefault()})}},10)};var F=d.buffer(function(){this.execCommand("save")},50);return h},{requires:"editor/core/base,editor/core/utils,editor/core/focusManager,editor/core/styles,editor/core/zIndexManager,editor/core/meta,editor/core/clipboard,editor/core/enterKey,editor/core/htmlDataProcessor,editor/core/selectionFix".split(",")});
