/*
Copyright 2013, KISSY UI Library v1.31
MIT Licensed
build time: Jul 29 13:11
*/
/*
 thanks to CKSource's intelligent work on CKEditor
 @author yiminghe@gmail.com
*/
KISSY.add("editor/core/base",function(e,h,p){h=p.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(e){return this._setData(e)}},formatData:{getter:function(){return this._getData(1)},setter:function(e){return this._setData(e)}},customStyle:{value:""},
customLink:{value:[]}}},{xclass:"editor"});h.HTML_PARSER={textarea:function(e){return e.one("."+this.get("prefixCls")+"editor-textarea")}};e.mix(h,e.EventTarget);return KISSY.Editor=h},{requires:["htmlparser","component/base","core"]});
KISSY.add("editor/core/clipboard",function(e,h,p,r){function m(f){this.editor=f;this._init()}function v(f){var c=f.get("document")[0],d=f.getSelection(),t;if(d.getType()==r.SELECTION_ELEMENT&&(t=d.getSelectedElement())){var f=d.getRanges()[0],a=b(c.createTextNode(""));a.insertBefore(t);f.setStartBefore(a);f.setEndAfter(t);d.selectRanges([f]);setTimeout(function(){t.parent()&&(a.remove(),d.selectElement(t))},0)}}var b=e.all,k=e.UA,o=k.ie?"beforepaste":"paste",n=h.RANGE;e.augment(m,{_init:function(){var f=
this,c=f.editor,d=c.get("document"),b=d.one("body"),a=function(a){this.type=a};a.prototype={exec:function(a){var d=this.type;a.focus();setTimeout(function(){k.ie&&("cut"==d?v(a):"paste"==d&&(f._preventPasteEvent(),f._getClipboardDataFromPasteBin()));j(a,d)||alert(w[d])},0)}};b.on(o,f._getClipboardDataFromPasteBin,f);k.ie&&(b.on("paste",f._iePaste,f),d.on("keydown",f._onKeyDown,f),d.on("contextmenu",function(){f._isPreventBeforePaste=1;setTimeout(function(){f._isPreventBeforePaste=0},0)}));c.addCommand("copy",
new a("copy"));c.addCommand("cut",new a("cut"));c.addCommand("paste",new a("paste"))},_onKeyDown:function(b){this.editor.get("mode")==h.WYSIWYG_MODE&&(b.ctrlKey&&86==b.keyCode||b.shiftKey&&45==b.keyCode)&&this._preventPasteEvent()},_stateFromNamedCommand:function(b){var c,d=this.editor;if("paste"==b){this._isPreventBeforePaste=1;try{c=d.get("document")[0].queryCommandEnabled(b)}catch(t){}this._isPreventBeforePaste=0}else c=(b=(b=d.getSelection())&&b.getRanges())&&!(1==b.length&&b[0].collapsed);return c},
_preventPasteEvent:function(){var b=this;b._preventPasteTimer&&clearTimeout(b._preventPasteTimer);b._isPreventPaste=1;b._preventPasteTimer=setTimeout(function(){b._isPreventPaste=0},70)},_iePaste:function(b){var c=this.editor;this._isPreventPaste||(b.preventDefault(),c.execCommand("paste"))},_getClipboardDataFromPasteBin:function(){if(!this._isPreventBeforePaste){var f=this.editor,c=f.get("document")[0];if(!c.getElementById("ke_pastebin")){var d=f.getSelection(),t=new p(c),a=b(k.webkit?"<body></body>":
"<div></div>",c);a.attr("id","ke_pastebin");k.webkit&&a[0].appendChild(c.createTextNode("\u200b"));c.body.appendChild(a[0]);a.css({position:"absolute",top:d.getStartElement().offset().top+"px",width:"1px",height:"1px",overflow:"hidden"});a.css("left","-1000px");var i=d.createBookmarks();t.setStartAt(a,n.POSITION_AFTER_START);t.setEndAt(a,n.POSITION_BEFORE_END);t.select(!0);setTimeout(function(){var c,b=a;a=k.webkit&&(c=a.first())&&c.hasClass("Apple-style-span")?c:a;d.selectBookmarks(i);var s=a.html();
b.remove();if(s=e.trim(s.replace(/<span[^>]+_ke_bookmark[^<]*?<\/span>(&nbsp;)*/ig,"")))c=f.fire("paste",{html:s}),!1!==c&&(void 0!==c&&(s=c),/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument)/.test(s)?e.use("editor/plugin/word-filter",function(a,c){f.insertHtml(c.toDataFormat(s,f))}):f.insertHtml(s))},0)}}}});var u=function(f,c){var d=f.get("document")[0],t=b(d.body),a=!1,i=function(){a=!0};t.on(c,i);(7<k.ie?d:d.selection.createRange()).execCommand(c);t.detach(c,i);return a},j=k.ie?function(b,c){return u(b,
c)}:function(b,c){try{return b.get("document")[0].execCommand(c)}catch(d){return!1}},w={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"},y={copy:"\u590d\u5236",paste:"\u7c98\u8d34",cut:"\u526a\u5207"};return{init:function(b){var c;b.docReady(function(){c=new m(b)});var d={copy:1,cut:1,paste:1},t=["copy","cut","paste"];b.on("contextmenu",function(a){var i=a.contextmenu;if(!i.__copy_fix){i.__copy_fix=1;for(a=0;a<
t.length;a++)i.addChild({content:y[t[a]],value:t[a]});i.on("click",function(a){var c=a.target.get("value");d[c]&&(i.hide(),setTimeout(function(){b.execCommand("save");b.execCommand(c);setTimeout(function(){b.execCommand("save")},10)},30))})}for(var g=i.get("children"),a=g.length-1;a--;0<=a){var l=g[a],s;s=l.get?l.get("value"):l.value;d[s]&&(s=!c._stateFromNamedCommand(s),l.set?l.set("disabled",s):l.disabled=s)}})}}},{requires:["./base","./range","./selection","node"]});
KISSY.add("editor/core/dom",function(e,h,p){function r(c,d){var b=c[d?"next":"prev"](m,1);if(b&&b[0].nodeType==k.ELEMENT_NODE){for(var a=[];b.attr("_ke_bookmark")||b._4e_isEmptyInlineRemovable(m);)if(a.push(b),b=d?b.next(m,1):b.prev(m,1),!b)return;if(c._4e_isIdentical(b,m)){for(var i=new n(d?c[0].lastChild:c[0].firstChild);a.length;)a.shift()._4e_move(c,!d,m);b._4e_moveChildren(c,!d,m);b.remove();i[0]&&i[0].nodeType==k.ELEMENT_NODE&&i._4e_mergeSiblings()}}}var m=m,v=h.XHTML_DTD,b=e.DOM,k=b.NodeType,
o=e.UA,n=e.Node,u={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 j=h.POSITION,w={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},y={hr:1},f=function(c){return c&&(c[0]||c)};p.injectDom({_4e_sameLevel:function(c,d){var d=f(d),b=c.parentNode;return b&&b==d.parentNode},_4e_isBlockBoundary:function(c,d){var f=e.merge(y,d);return!(!w[b.css(c,"display")]&&!f[b.nodeName(c)])},_4e_index:function(c,d){for(var b=c.parentNode.childNodes,a,i=-1,g=0;g<b.length;g++)if(a=b[g],!d||!(3==a.nodeType&&a.previousSibling&&3==a.previousSibling.nodeType))if(i++,a===c)return i;return-1},_4e_move:function(c,
d,b){d=f(d);b?d.insertBefore(c,d.firstChild):d.appendChild(c)},_4e_isIdentical:function(c,d){if(!d)return!1;d=f(d);if(b.nodeName(c)!=b.nodeName(d))return!1;var t=c.attributes,a=d.attributes,i=t.length,g=a.length;if(i!=g)return!1;for(var l=0;l<i;l++){var s=t[l],j=s.name;if(s.specified&&b.attr(c,j)!=b.attr(d,j))return!1}if(8>p.ieEngine)for(l=0;l<g;l++)if(s=a[l],j=s.name,s.specified&&b.attr(c,j)!=b.attr(d,j))return!1;return!0},_4e_isEmptyInlineRemovable:function(c){if(!v.$removeEmpty[b.nodeName(c)])return!1;
for(var c=c.childNodes,d=0,f=c.length;d<f;d++){var a=c[d],i=a.nodeType;if(!(i==k.ELEMENT_NODE&&a.getAttribute("_ke_bookmark"))&&(i==k.ELEMENT_NODE&&!b._4e_isEmptyInlineRemovable(a)||i==b.NodeType.TEXT_NODE&&e.trim(a.nodeValue)))return!1}return!0},_4e_moveChildren:function(c,d,b){d=f(d);if(c!=d)if(b)for(;b=c.lastChild;)d.insertBefore(c.removeChild(b),d.firstChild);else for(;b=c.firstChild;)d.appendChild(c.removeChild(b))},_4e_mergeSiblings:function(c){c=new n(c);u[c.nodeName()]&&(r(c,!0),r(c))},_4e_splitText:function(c,
d){var f=c.ownerDocument;if(c.nodeType==b.NodeType.TEXT_NODE){if(o.ie&&d==c.nodeValue.length){var a=f.createTextNode("");b.insertAfter(a,c);return a}a=c.splitText(d);f.documentMode&&(f=f.createTextNode(""),b.insertAfter(f,a),b.remove(f));return a}},_4e_parents:function(c,d){var b=[];b.__IS_NODELIST=1;do b[d?"push":"unshift"](c);while(c=c.parentNode);return b},_4e_nextSourceNode:function(c,d,j,a){if(a&&!a.call)var i=f(a),a=function(a){return a!==i};var d=!d&&c.firstChild,g=c;if(!d){if(c.nodeType==
k.ELEMENT_NODE&&a&&!1===a(c,!0))return null;d=c.nextSibling}for(;!d&&(g=g.parentNode);){if(a&&!1===a(g,!0))return null;d=g.nextSibling}return!d||a&&!1===a(d)?null:j&&j!=d.nodeType?b._4e_nextSourceNode(d,!1,j,a):d},_4e_previousSourceNode:function(c,d,j,a){if(a&&!a.call)var i=f(a),a=function(a){return a!==i};var d=!d&&c.lastChild,g=c;if(!d){if(c.nodeType==k.ELEMENT_NODE&&a&&!1===a(c,!0))return null;d=c.previousSibling}for(;!d&&(g=g.parentNode);){if(a&&!1===a(g,!0))return null;d=g.previousSibling}return!d||
a&&!1===a(d)?null:j&&d.nodeType!=j?b._4e_previousSourceNode(d,!1,j,a):d},_4e_commonAncestor:function(c,d){d=f(d);if(c===d)return c;if(b.contains(d,c))return d;var j=c;do if(b.contains(j,d))return j;while(j=j.parentNode);return null},_4e_hasAttributes:9>p.ieEngine?function(c){for(var d=c.attributes,b=0;b<d.length;b++){var a=d[b];switch(a.name){case "class":if(c.getAttribute("class"))return!0;break;default:if(a.specified)return!0}}return!1}:function(c){o.gecko&&c.removeAttribute("_moz_dirty");return c.hasAttributes()},
_4e_position:function(c,d){var e=f(d);if(c.compareDocumentPosition)return c.compareDocumentPosition(e);if(c==e)return j.POSITION_IDENTICAL;if(c.nodeType==k.ELEMENT_NODE&&e.nodeType==k.ELEMENT_NODE){if(b.contains(c,e))return j.POSITION_CONTAINS+j.POSITION_PRECEDING;if(b.contains(e,c))return j.POSITION_IS_CONTAINED+j.POSITION_FOLLOWING;if("sourceIndex"in c)return 0>c.sourceIndex||0>e.sourceIndex?j.POSITION_DISCONNECTED:c.sourceIndex<e.sourceIndex?j.POSITION_PRECEDING:j.POSITION_FOLLOWING}for(var a=
b._4e_address(c),e=b._4e_address(e),i=Math.min(a.length,e.length),g=0;g<=i-1;g++)if(a[g]!=e[g])return a[g]<e[g]?j.POSITION_PRECEDING:j.POSITION_FOLLOWING;return a.length<e.length?j.POSITION_CONTAINS+j.POSITION_PRECEDING:j.POSITION_IS_CONTAINED+j.POSITION_FOLLOWING},_4e_address:function(c,d){for(var f=[],a=c.ownerDocument.documentElement,i=c;i&&i!=a;)f.unshift(b._4e_index(i,d)),i=i.parentNode;return f},_4e_remove:function(c,d){var b=c.parentNode;if(b){if(d)for(var a;a=c.firstChild;)b.insertBefore(c.removeChild(a),
c);b.removeChild(c)}return c},_4e_trim:function(c){b._4e_ltrim(c);b._4e_rtrim(c)},_4e_ltrim:function(c){for(var d;d=c.firstChild;){if(d.nodeType==b.NodeType.TEXT_NODE){var f=p.ltrim(d.nodeValue),a=d.nodeValue.length;if(f)f.length<a&&(b._4e_splitText(d,a-f.length),c.removeChild(c.firstChild));else{c.removeChild(d);continue}}break}},_4e_rtrim:function(c){for(var d;d=c.lastChild;){if(d.type==b.NodeType.TEXT_NODE){var f=p.rtrim(d.nodeValue),a=d.nodeValue.length;if(f)f.length<a&&(b._4e_splitText(d,f.length),
c.removeChild(c.lastChild));else{c.removeChild(d);continue}}break}!o.ie&&!o.opera&&(d=c.lastChild)&&1==d.nodeType&&"br"==b.nodeName(d)&&c.removeChild(d)},_4e_appendBogus:function(c){for(var d=c.lastChild;d&&d.nodeType==b.NodeType.TEXT_NODE&&!e.trim(d.nodeValue);)d=d.previousSibling;if(!d||d.nodeType==b.NodeType.TEXT_NODE||"br"!==b.nodeName(d))d=o.opera?c.ownerDocument.createTextNode(""):c.ownerDocument.createElement("br"),c.appendChild(d)},_4e_setMarker:function(c,d,b,a){var c=new n(c),i=c.data("list_marker_id")||
c.data("list_marker_id",e.guid()).data("list_marker_id"),g=c.data("list_marker_names")||c.data("list_marker_names",{}).data("list_marker_names");d[i]=c;g[b]=1;return c.data(b,a)},_4e_clearMarkers:function(c,d,b){var c=new n(c),a=c.data("list_marker_names"),i=c.data("list_marker_id"),g;for(g in a)c.removeData(g);c.removeData("list_marker_names");b&&(c.removeData("list_marker_id"),delete d[i])},_4e_copyAttributes:function(c,d,f){for(var d=new n(d),a=c.attributes,f=f||{},i=0;i<a.length;i++){var g=a[i],
l=g.name.toLowerCase(),s;if(!(l in f))if("checked"==l&&(s=b.attr(c,l)))d.attr(l,s);else if(g.specified||o.ie&&g.value&&"value"==l)s=b.attr(c,l),null===s&&(s=g.nodeValue),d.attr(l,s)}""!==c.style.cssText&&(d[0].style.cssText=c.style.cssText)},_4e_isEditable:function(c){c=b.nodeName(c);return(c=!v.$nonEditable[c]&&(v[c]||v.span))&&c["#text"]},_4e_getByAddress:function(c,d,b){for(var c=c.documentElement,a=0;c&&a<d.length;a++){var i=d[a];if(b)for(var g=-1,l=0;l<c.childNodes.length;l++){var f=c.childNodes[l];
if(!(!0===b&&3==f.nodeType&&f.previousSibling&&3==f.previousSibling.nodeType)&&(g++,g==i)){c=f;break}}else c=c.childNodes[i]}return c}})},{requires:["./base","./utils","node"]});
KISSY.add("editor/core/domIterator",function(e,h){function p(b){1>arguments.length||(this.range=b,this.forceBrBreak=m,this.enlargeBr=r,this.enforceRealBlocks=m,this._||(this._={}))}var r=!0,m=!1,v=e.UA,b=h.Walker,k=h.Range,o=h.RANGE,n=h.ElementPath,u=e.Node,j=e.DOM,w=/^[\r\n\t ]*$/;e.augment(p,{getNextParagraph:function(h){var f,c,d,t,a;if(!this._.lastNode){c=this.range.clone();c.shrink(o.SHRINK_ELEMENT,r);c.enlarge(this.forceBrBreak||!this.enlargeBr?o.ENLARGE_LIST_ITEM_CONTENTS:o.ENLARGE_BLOCK_CONTENTS);
var i=new b(c),g=b.bookmark(r,r);i.evaluator=g;this._.nextNode=i.next();i=new b(c);i.evaluator=g;i=i.previous();this._.lastNode=i._4e_nextSourceNode(r);this._.lastNode&&this._.lastNode[0].nodeType==j.NodeType.TEXT_NODE&&!e.trim(this._.lastNode[0].nodeValue)&&this._.lastNode.parent()._4e_isBlockBoundary()&&(g=new k(c.document),g.moveToPosition(this._.lastNode,o.POSITION_AFTER_END),g.checkEndOfBlock()&&(g=new n(g.endContainer),this._.lastNode=(g.block||g.blockLimit)._4e_nextSourceNode(r)));this._.lastNode||
(this._.lastNode=this._.docEndMarker=new u(c.document.createTextNode("")),j.insertAfter(this._.lastNode[0],i[0]));c=null}g=this._.nextNode;i=this._.lastNode;for(this._.nextNode=null;g;){var l=m,s=g[0].nodeType!=j.NodeType.ELEMENT_NODE,B=m;if(s)g[0].nodeType==j.NodeType.TEXT_NODE&&w.test(g[0].nodeValue)&&(s=m);else{var C=g.nodeName();if(g._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){if("br"==C)s=r;else if(!c&&!g[0].childNodes.length&&"hr"!=C){f=g;d=g.equals(i);break}c&&(c.setEndAt(g,o.POSITION_BEFORE_START),
"br"!=C&&(this._.nextNode=g));l=r}else{if(g[0].firstChild){c||(c=new k(this.range.document),c.setStartAt(g,o.POSITION_BEFORE_START));g=new u(g[0].firstChild);continue}s=r}}s&&!c&&(c=new k(this.range.document),c.setStartAt(g,o.POSITION_BEFORE_START));d=(!l||s)&&g.equals(i);if(c&&!l)for(;!g[0].nextSibling&&!d;){C=g.parent();if(C._4e_isBlockBoundary(this.forceBrBreak&&{br:1})){l=r;d||C.equals(i);break}g=C;s=r;d=g.equals(i);B=r}s&&c.setEndAt(g,o.POSITION_AFTER_END);g=g._4e_nextSourceNode(B,null,i);if((d=
!g)||l&&c)break}if(!f){if(!c)return this._.docEndMarker&&this._.docEndMarker._4e_remove(),this._.nextNode=null;f=new n(c.startContainer);g=f.blockLimit;l={div:1,th:1,td:1};f=f.block;if((!f||!f[0])&&!this.enforceRealBlocks&&l[g.nodeName()]&&c.checkStartOfBlock()&&c.checkEndOfBlock())f=g;else if(!f||this.enforceRealBlocks&&"li"==f.nodeName())f=new u(this.range.document.createElement(h||"p")),f[0].appendChild(c.extractContents()),f._4e_trim(),c.insertNode(f),t=a=r;else if("li"!=f.nodeName()){if(!c.checkStartOfBlock()||
!c.checkEndOfBlock())f=f.clone(m),f[0].appendChild(c.extractContents()),f._4e_trim(),a=c.splitBlock(),t=!a.wasStartOfBlock,a=!a.wasEndOfBlock,c.insertNode(f)}else d||(this._.nextNode=f.equals(i)?null:c.getBoundaryNodes().endNode._4e_nextSourceNode(r,null,i))}t&&(c=new u(f[0].previousSibling),c[0]&&c[0].nodeType==j.NodeType.ELEMENT_NODE&&("br"==c.nodeName()?c._4e_remove():c[0].lastChild&&"br"==j.nodeName(c[0].lastChild)&&j._4e_remove(c[0].lastChild)));a&&(c=b.bookmark(m,r),t=new u(f[0].lastChild),
t[0]&&t[0].nodeType==j.NodeType.ELEMENT_NODE&&"br"==t.nodeName()&&(v.ie||t.prev(c,1)||t.next(c,1))&&t.remove());this._.nextNode||(this._.nextNode=d||f.equals(i)?null:f._4e_nextSourceNode(r,null,i));return f}});k.prototype.createIterator=function(){return new p(this)};return p},{requires:["./base","./range","./elementPath","./walker","node"]});
KISSY.add("editor",function(e,h,p,r,m,v,b,k,o,n){function u(d,b){var g=d.body;D(function(){d.designMode="on";setTimeout(function(){d.designMode="off";g.focus();arguments.callee.retry||(arguments.callee.retry=c)},50)},function(){d.designMode="off";s.attr(g,"contentEditable",a);s.attr(g,"contentEditable",c);!b&&u(d,1)})}function j(d){d.get("iframe");var c=d.get("textarea")[0],b=d.get("window")[0],q=d.get("document")[0];g.webkit&&(z.on(q,"click",function(d){var a=new C(d.target);e.inArray(a.nodeName(),
["input","select"])&&d.preventDefault()}),z.on(q,"mouseup",function(d){var a=new C(d.target);e.inArray(a.nodeName(),["input","textarea"])&&d.preventDefault()}));if(g.gecko||l||g.opera){var i;i=(new C('<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>')).insertAfter(c);i.on("focus",function(){d.focus()});d.activateGecko=function(){g.gecko&&d.__iframeFocus&&i[0].focus()};d.on("destroy",function(){i.detach();i.remove()})}z.on(b,"focus",function(){g.gecko?u(q,a):g.opera&&
q.body.focus();d.notifySelectionChange()});if(g.gecko)z.on(q,"mousedown",function(){d.__iframeFocus||u(q,a)});if(l&&(z.on(q,"keydown",function(a){if(a.keyCode in{8:1,46:1}){var c=d.getSelection(),b=c.getSelectedElement();if(b){d.execCommand("save");var g=c.getRanges()[0].createBookmark();b.remove();c.selectBookmarks([g]);d.execCommand("save");a.preventDefault()}}}),"CSS1Compat"==q.compatMode)){var x={33:1,34:1};z.on(q,"keydown",function(a){a.keyCode in x&&setTimeout(function(){d.getSelection().scrollIntoView()},
0)})}if(g.webkit)z.on(q,"mousedown",function(a){a=new C(a.target);e.inArray(a.nodeName(),["img","hr","input","textarea","select"])&&d.getSelection().selectElement(a)});if(g.gecko)z.on(q,"dragstart",function(a){var d=new C(a.target);d.nodeName()==="img"&&/ke_/.test(d[0].className)&&a.preventDefault()});r.add(d)}function w(a,d,c,b){var g="",q,l=p.debugUrl("theme/editor-iframe.css");for(q=0;q<c.length;q++)g+=e.substitute('<link href="{href}" rel="stylesheet" />',{href:c[q]});return e.substitute(G,{doctype:8===
i.documentMode?'<meta http-equiv="X-UA-Compatible" content="IE=7" />':"",title:"${title}",links:g,href:l,style:d,data:b||"&nbsp;",script:a?'<script id="ke_active_script">'+(s.isCustomDomain()?'document.domain="'+i.domain+'";':"")+'parent.KISSY.Editor._initIFrame("'+a+'");<\/script>':""})}function y(a,d){function c(){x=i.document;a.setInternal("document",new C(x));a.setInternal("window",new C(i));b.detach();x.open("text/html","replace");x.write(g);x.close()}var b=a.get("iframe"),g=w(a._UUID,a.get("customStyle"),
a.get("customLink"),d),q=b[0],i=q.contentWindow,x;b.__loaded=1;try{x=i.document}catch(f){if(q.src=q.src,7>l){setTimeout(c,10);return}}c()}function f(a,d){var c=s.getEmptyIframeSrc()||"";c&&(c=' src="'+c+'" ');var c=new C(e.substitute(q,{iframeSrc:c})),b=a.get("textarea");b.hasAttr("tabindex")&&c.attr("tabIndex",g.webkit?-1:b.attr("tabIndex"));b.parent().prepend(c);a.set("iframe",c);a.__docReady=0;if(g.gecko&&!c.__loaded)c.on("load",function(){y(a,d)},a);else y(a,d)}var c=!0,d=d,t=e.all,a=!1,i=document,
g=e.UA,l=g.ie,s=e.DOM,B=s.NodeType,C=e.Node,z=e.Event,D=p.tryThese,G="<!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>",q='<iframe style="width:100%;height:100%;border:none;"  frameborder="0"  title="kissy-editor"  allowTransparency="true"  {iframeSrc} ></iframe>',x='<div class="{prefixCls}editor-tools"></div><div class="{prefixCls}editor-textarea-wrap" '+(g.mobile?
'style="overflow:scroll;-webkit-overflow-scrolling:touch;"':"")+"></div><div class='{prefixCls}editor-status'></div>";e.mix(h,{SOURCE_MODE:0,WYSIWYG_MODE:1});var I=h.WYSIWYG_MODE;e.augment(h,{createDom:function(){var a,d=this.get("prefixCls"),c=this.get("textarea"),b;c?(this.set("textarea",c=t(c)),c[0].parentNode&&c[0].parentNode.removeChild(c[0])):this.set("textarea",c=t("<textarea class='"+d+"-editor-textarea'></textarea>"));b=this.get("el");b.html(e.substitute(x,{prefixCls:d}));a=b.one(e.substitute(".{prefixCls}editor-textarea-wrap",
{prefixCls:d}));this._UUID=e.guid();this.set({toolBarEl:b.one(e.substitute(".{prefixCls}editor-tools",{prefixCls:d})),statusBarEl:b.one(e.substitute(".{prefixCls}editor-status",{prefixCls:d}))},{silent:1});c.css("width","100%");c.css("display","none");a.append(c);r.register(this)},renderUI:function(){b.init(this);k.init(this);o.init(this);n.init(this)},bindUI:function(){function a(){d.detach("docReady",a);if(d.get("focused"))d.focus();else{var c=d.getSelection();c&&c.removeAllRanges()}}var d=this,
c,b=d.get("prefixCls"),g=d.get("textarea");if(d.get("attachForm")&&(c=g[0].form))z.on(c,"submit",d.sync,d),d.on("destroy",function(){z.detach(c,"submit",d.sync,d)});d.on("docReady",a);d.on("blur",function(){d.get("el").removeClass(b+"editor-focused")});d.on("focus",function(){d.get("el").addClass(b+"editor-focused")})},_onSetHeight:function(d){var a=this.get("textarea"),c=this.get("toolBarEl"),b=this.get("statusBarEl"),d=parseInt(d,10),d=d-((c&&c.outerHeight()||0)+(b&&b.outerHeight()||0));a.parent().css("height",
d);a.css("height",d)},_onSetMode:function(d){var a=this,c,b=a.get("rendered"),g=a.get("iframe"),q=a.get("textarea");d==I?(b&&a.execCommand("save"),a.on("docReady",c=function(){b&&a.execCommand("save");a.detach("docReady",c)}),a._setData(q.val()),q.hide(),a.fire("wysiwygMode")):(g&&(q.val(a._getData(1,I)),g.hide()),q.show(),a.fire("sourceMode"))},_onSetFocused:function(a){a&&this.__docReady&&this.focus()},destructor:function(){var a=this.get("document")[0],d=this.get("window");this.sync();r.remove(this);
z.remove([a,a.documentElement,a.body,d[0]]);e.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,d){this.__controls[a]=d},showDialog:function(a,d){var a=a+"/dialog",c=this.__controls[a];c.show(d);this.fire("dialogShow",{dialog:c.dialog,pluginDialog:c,dialogName:a})},addCommand:function(a,d){this.__commands[a]=d},hasCommand:function(a){return this.__commands[a]},
execCommand:function(a){var c=this.__commands[a],b=e.makeArray(arguments);b.shift();b.unshift(this);return c?c.exec.apply(c,b):d},queryCommandValue:function(a){return this.execCommand(p.getQueryCmd(a))},_getData:function(a,c){var b=this.htmlDataProcessor,g;c==d&&(c=this.get("mode"));g=c==I?this.get("document")[0].body.innerHTML:b.toDataFormat(this.get("textarea").val());g=a?b.toHtml(g):b.toServer(g);g=e.trim(g);/^(?:<(p)>)?(?:(?:&nbsp;)|\s)*(?:<\/\1>)?$/.test(g)&&(g="");return g},_setData:function(a){var d,
c=a;if(this.get("mode")!=I)this.get("textarea").val(a);else{if(d=this.htmlDataProcessor)c=d.toDataFormat(a);if(this.get("iframe")){a=this.get("iframe");d=this.get("window")[0];var b=this.get("document")[0];z.remove([b,b.documentElement,b.body,d]);a.remove()}f(this,c)}},sync:function(){this.get("textarea").val(this.get("data"))},getDocHtml:function(){return w(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("window");if(a){var d=this.get("document")[0],a=a[0];g.ie||a&&a.parent&&a.parent.focus();a&&a.focus();try{d.body.focus()}catch(c){}this.notifySelectionChange()}},blur:function(){this.get("window")[0].blur();this.get("document")[0].body.blur()},addCustomStyle:function(a,d){var c=this.get("window"),b=this.get("customStyle")||"";this.set("customStyle",b+("\n"+a));c&&s.addStyleSheet(c,a,d)},removeCustomStyle:function(a){s.remove(s.get("#"+a,this.get("window")[0]))},addCustomLink:function(a){var d=
this.get("customLink")||[],c=this.get("document")[0];d.push(a);this.set("customLink",d);d=c.createElement("link");d.rel="stylesheet";c.getElementsByTagName("head")[0].appendChild(d);d.href=a},removeCustomLink:function(a){for(var d=this.get("document")[0],d=s.query("link",d),c=0;c<d.length;c++)s.attr(d[c],"href")==a&&s.remove(d[c]);d=this.get("customLink")||[];a=e.indexOf(a,d);-1!=a&&d.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 d=a.getSelection();if(d&&!d.isInvalid){var c=d.getStartElement(),b=new h.ElementPath(c);if(!a.__previousPath||!a.__previousPath.compare(b))a.__previousPath=b,a.fire("selectionChange",{selection:d,path:b,element:c})}},100)},notifySelectionChange:function(){this.__previousPath=null;this.checkSelectionChange()},insertElement:function(a){if(this.get("mode")!==I)return d;this.focus();
var b,g=a.nodeName(),q=h.XHTML_DTD,i=q.$block[g],l=h.RANGE,x=(g=this.getSelection())&&g.getRanges(),f,s,j;if(!x||0==x.length)return d;this.execCommand("save");for(s=x.length-1;0<=s;s--)f=x[s],b=!s&&a||a.clone(c),f.insertNodeByDtd(b),j||(j=b);if(!j)return d;f.moveToPosition(j,l.POSITION_AFTER_END);i&&(a=h.Walker.whitespaces(!0),(a=(j=j.next(a,1))&&j[0].nodeType==B.ELEMENT_NODE&&j.nodeName())&&q.$block[a]&&q[a]["#text"]&&f.moveToElementEditablePosition(j));g.selectRanges([f]);this.focus();b&&1==b[0].nodeType&&
b.scrollIntoView(d,{alignWithTop:!1,allowHorizontalScroll:!0,onlyScrollIfNeeded:!0});F.call(this);return b},insertHtml:function(c,b){var g=this,q,i=g.get("document")[0];if(g.get("mode")===I){if(q=g.htmlDataProcessor)c=q.toDataFormat(c,b);g.focus();g.execCommand("save");if(l){q=i.selection;"Control"==q.type&&q.clear();try{q.createRange().pasteHTML(c)}catch(x){}}else try{i.execCommand("inserthtml",a,c)}catch(f){setTimeout(function(){if(0==g.getSelection().getRanges().length){var b=new h.Range(i),q=
s.first(i.body,function(a){return 1==a.nodeType&&"br"!=s.nodeName(a)});q||(q=new C(i.createElement("p")),q._4e_appendBogus(d),i.body.appendChild(q[0]));b.setStartAt(q,h.RANGE.POSITION_AFTER_START);b.select()}i.execCommand("inserthtml",a,c)},50)}setTimeout(function(){g.getSelection().scrollIntoView()},50);F.call(g)}},insertHTML:function(a,d){return this.insertHtml(a,d)}});h._initIFrame=function(d){var b=r.getInstance(d),q=b.get("document")[0],d=q.getElementById("ke_active_script");s.remove(d);j(b);
var i=q.body;l?(i.hideFocus=c,i.disabled=c,i.contentEditable=c,i.removeAttribute("disabled")):setTimeout(function(){g.gecko||g.opera?i.contentEditable=c:g.webkit?i.parentNode.contentEditable=c:q.designMode="on"},0);if(g.gecko||g.opera){var x=q.documentElement;z.on(x,"mousedown",function(d){if(d.target==x){g.gecko&&u(q,a);b.activateGecko()}})}setTimeout(function(){l&&setTimeout(function(){if(q){i.runtimeStyle.marginBottom="0px";i.runtimeStyle.marginBottom=""}},1E3)},0);setTimeout(function(){b.__docReady=
1;b.fire("docReady");var d=b.get("disableObjectResizing"),c=b.get("disableInlineTableEditing");if(d||c)try{q.execCommand("enableObjectResizing",a,!d);q.execCommand("enableInlineTableEditing",a,!c)}catch(g){z.on(i,l?"resizestart":"resize",function(a){var b=new C(a.target);(d||b.nodeName()==="table"&&c)&&a.preventDefault()})}},10)};var F=e.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/clipboard,editor/core/enterKey,editor/core/htmlDataProcessor,editor/core/selectionFix".split(",")});
KISSY.add("editor/core/elementPath",function(e,h){function p(e){for(var n=v,h=v,j=[];e;){if(e[0].nodeType==r.NodeType.ELEMENT_NODE){this.lastElement||(this.lastElement=e);var w=e.nodeName();if(!h&&(!n&&b[w]&&(n=e),k[w])){var p;if(p=!n)if(p="div"==w){a:{p=e[0].childNodes;for(var f=0,c=p.length;f<c;f++){var d=p[f];if(d.nodeType==r.NodeType.ELEMENT_NODE&&m.$block[d.nodeName.toLowerCase()]){p=!0;break a}}p=!1}p=!p}p?n=e:h=e}j.push(e);if("body"==w)break}e=e.parent()}this.block=n;this.blockLimit=h;this.elements=
j}var r=e.DOM,m=h.XHTML_DTD,v=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};p.prototype={constructor:p,compare:function(b){var e=this.elements,b=b&&b.elements;if(!b||e.length!=b.length)return!1;for(var k=0;k<e.length;k++)if(!r.equals(e[k],b[k]))return!1;return!0},contains:function(b){for(var e=this.elements,k=0;k<e.length;k++)if(e[k].nodeName()in b)return e[k];return v},toString:function(){var b=
this.elements,e,k=[];for(e=0;e<b.length;e++)k.push(b[e].nodeName());return k.toString()}};return h.ElementPath=p},{requires:["./base","./dom","node"]});
KISSY.add("editor/core/enterKey",function(e,h,p,r){function m(j){var h;h=j.getSelection().getRanges();for(var m=h.length-1;0<m;m--)h[m].deleteContents();h=h[0];m=h.document;if(h.checkStartOfBlock()&&h.checkEndOfBlock()){var f=(new r(h.startContainer)).block;if(f&&("li"==f.nodeName()||"li"==f.parent().nodeName()))return j.hasCommand("outdent")?(j.execCommand("save"),j.execCommand("outdent"),j.execCommand("save"),!0):!1}var c=h.splitBlock("p");if(!c)return!0;var j=c.previousBlock,f=c.nextBlock,d=c.wasStartOfBlock,
t=c.wasEndOfBlock,a;if(f)a=f.parent(),"li"==a.nodeName()&&(f._4e_breakParent(a),f._4e_move(f.next(),!0));else if(j&&(a=j.parent())&&"li"==a.nodeName())j._4e_breakParent(a),h.moveToElementEditablePosition(j.next()),j._4e_move(j.prev());if(!d&&!t){if("li"==f.nodeName()&&(a=f.first(p.invisible(!0)))&&e.inArray(a.nodeName(),["ul","ol"]))(b.ie?new n(m.createTextNode("\u00a0")):new n(m.createElement("br"))).insertBefore(a);f&&h.moveToElementEditablePosition(f)}else{var i;if(j){if("li"==j.nodeName()||!k.test(j.nodeName()))i=
j.clone()}else f&&(i=f.clone());i||(i=new n("<p>",null,m));if(a=c.elementPath)for(var c=0,g=a.elements.length;c<g;c++){var l=a.elements[c];if(l.equals(a.block)||l.equals(a.blockLimit))break;o.$removeEmpty[l.nodeName()]&&(l=l.clone(),i._4e_moveChildren(l),i.append(l))}b.ie||i._4e_appendBogus();h.insertNode(i);if(b.ie&&d&&(!t||!j[0].childNodes.length))h.moveToElementEditablePosition(t?j:i),h.select();h.moveToElementEditablePosition(d&&!t?f:i)}b.ie||(f?(i=new n(m.createElement("span")),i.html("&nbsp;"),
h.insertNode(i),i.scrollIntoView(void 0,{alignWithTop:!1,allowHorizontalScroll:!0,onlyScrollIfNeeded:!0}),h.deleteContents()):i.scrollIntoView(void 0,{alignWithTop:!1,allowHorizontalScroll:!0,onlyScrollIfNeeded:!0}));h.select();return!0}function v(b){var e=b.get("document")[0];u.on(e,"keydown",function(e){if(13===e.keyCode&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){b.execCommand("save");var f=b.execCommand("enterBlock");b.execCommand("save");!1!==f&&e.preventDefault()}})}var b=e.UA,k=/^h[1-6]$/,o=h.XHTML_DTD,
n=e.Node,u=e.Event;return{init:function(b){b.addCommand("enterBlock",{exec:m});b.docReady(function(){v(b)})}}},{requires:["./base","./walker","./elementPath","node"]});
KISSY.add("editor/core/focusManager",function(e){function h(){var e=this;e.__iframeFocus=o;k=e;b&&clearTimeout(b);b=setTimeout(function(){e.fire("focus")},100)}function p(){var e=this;e.__iframeFocus=n;k=u;b&&clearTimeout(b);b=setTimeout(function(){e.fire("blur")},100)}var r=e.Editor,m=e.Event,v={},b,k,e={refreshAll:function(){for(var b in v){var e=v[b].get("document")[0];e.designMode="off";e.designMode="on"}},currentInstance:function(){return k},getInstance:function(b){return v[b]},add:function(b){var e=
b.get("window")[0];m.on(e,"focus",h,b);m.on(e,"blur",p,b)},register:function(b){v[b._UUID]=b},remove:function(b){delete v[b._UUID];var e=b.get("window")[0];m.remove(e,"focus",h,b);m.remove(e,"blur",p,b)}},o=!0,n=!1,u=null;e.refreshAll=e.refreshAll;r.focusManager=e;r.getInstances=function(){return v};return e},{requires:["./base","./dom"]});
KISSY.add("editor/core/htmlDataProcessor",function(e,h,p){return{init:function(r){function m(a){var a=a.childNodes,d,b,c,i=a.length;if(i){c=1;for(d=0;d<i;d++)if(b=a[d],b.nodeType!=e.DOM.NodeType.TEXT_NODE||b.nodeValue){c=0;break}return c?!1:void 0}return!1}function v(a){return a.replace(w,function(a,d,b){return"<"+d+b.replace(y,function(a,d){return-1==b.indexOf("_ke_saved_"+d)?" _ke_saved_"+a+" "+a:a})+">"})}function b(a){return a.replace(c,function(a){return"<ke:encoded>"+encodeURIComponent(a)+"</ke:encoded>"})}
function k(a){return a.replace(d,function(a,d){return e.urlDecode(d)})}var o=e.Node,n=e.UA,u=new p.Filter,j=new p.Filter;(function(){function a(d){d=p.serialize(d);return new p.Comment(f+encodeURIComponent(d).replace(/--/g,"%2D%2D"))}var d={tagNames:[[/^\?xml.*$/i,""],[/^.*namespace.*$/i,""]],attributeNames:[[/^on/,"ke_on"],[/^lang$/,""]],tags:{script:a,noscript:a,span:m}},b={tagNames:[[/^ke:/,""],[/^\?xml:namespace$/,""]],tags:{$:function(a){if(a.attributes.length)for(var d=["name","href","src"],
b,c=0;c<d.length;c++)b="_ke_saved_"+d[c],a.getAttribute(b)&&a.removeAttribute(d[c]);return a},embed:function(a){var d=a.parentNode;if(d&&"object"==d.nodeName){var b=d.getAttribute("width"),d=d.getAttribute("height");b&&a.setAttribute("width",b);d&&a.setAttribute("width",d)}},a:function(a){if(!a.childNodes.length&&!a.attributes.length)return!1},span:m,strong:m,em:m,del:m,u:m},attributes:{style:function(a){if(!e.trim(a))return!1}},attributeNames:[[/^_ke_saved_/,""],[/^ke_on/,"on"],[/^_ke.*/,""],[/^ke:.*$/,
""],[/^_ks.*/,""]],comment:function(a){if(a.substr(0,f.length)==f)return a=e.trim(e.urlDecode(a.substr(f.length))),p.parse(a).childNodes[0]}};n.ie&&(b.attributes.style=function(a){return a.replace(/(^|;)([^:]+)/g,function(a){return a.toLowerCase()})});u.addRules(b);j.addRules(d)})();(function(){function a(d){for(var d=d.childNodes,b=d.length,c=d[b-1];c&&3==c.nodeType&&!e.trim(c.nodeValue);)c=d[--b];return c}function d(b){var c=a(b);c&&(1==c.nodeType&&"br"==c.nodeName?b.removeChild(c):3==c.nodeType&&
f.test(c.nodeValue)&&b.removeChild(c))}function b(d){var c=a(d);return!c||"form"==d.nodeName&&"input"==c.nodeName}function c(a){d(a);b(a)&&(n.ie||a.appendChild(new p.Tag("br")))}function i(a){d(a);b(a)&&a.appendChild(new p.Text("\u00a0"))}var f=/^[\t\r\n ]*(?:&nbsp;|\xa0)[\t\r\n ]*$/,k=h.XHTML_DTD,o=e.merge(k.$block,k.$listItem,k.$tableContent),q;for(q in o)"br"in k[q]||delete o[q];delete o.pre;var k={tags:{}},x={tags:{}};for(q in o)k.tags[q]=c,x.tags[q]=i;j.addRules(k);u.addRules(x)})();u.addRules({text:function(a){return a.replace(/\xa0/g,
"&nbsp;")}});var w=/<(a|area|img|input)\b([^>]*)>/gi,y=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,f="{ke_protected}",c=/(?:<textarea[^>]*>[\s\S]*<\/textarea>)|(?:<style[^>]*>[\s\S]*<\/style>)|(?:<script[^>]*>[\s\S]*<\/script>)|(?:<(:?link|meta|base)[^>]*>)/gi,d=/<ke:encoded>([^<]*)<\/ke:encoded>/gi,t=/(<\/?)((?:object|embed|param|html|body|head|title|noscript)[^>]*>)/gi,a=/(<\/?)ke:((?:object|embed|param|html|body|head|title|noscript)[^>]*>)/gi,i=/<ke:(param|embed)([^>]*?)\/?>(?!\s*<\/ke:\1)/gi;
r.htmlDataProcessor={dataFilter:j,htmlFilter:u,toHtml:function(a){n.webkit&&(a=a.replace(/\u200b/g,""));var d=new p.BeautifyWriter;(new p.Parser(a)).parse().writeHtml(d,u);return a=d.getHtml()},toDataFormat:function(d,c){var c=c||j,d=b(d),d=v(d),d=d.replace(t,"$1ke:$2"),d=d.replace(i,"<ke:$1$2></ke:$1>"),f=new o("<div>");f.html("a"+d);d=f.html().substr(1);d=d.replace(a,"$1$2");d=k(d);f=new p.BasicWriter;(new p.Parser(d)).parse().writeHtml(f,c);return d=f.getHtml()},toServer:function(a){var d=new p.MinifyWriter;
(new p.Parser(a)).parse().writeHtml(d,u);return d.getHtml()}}}}},{requires:["./base","htmlparser"]});
KISSY.config("modules",{"editor/plugin/heading/cmd":{requires:["editor"]},"editor/plugin/page-break/index":{requires:["editor","editor/plugin/fake-objects/"]},"editor/plugin/italic/cmd":{requires:["editor","editor/plugin/font/cmd"]},"editor/plugin/font-size/cmd":{requires:["editor","editor/plugin/font/cmd"]},"editor/plugin/image/dialog":{requires:["ajax","editor","editor/plugin/overlay/","tabs","editor/plugin/menubutton/"]},"editor/plugin/underline/index":{requires:["editor","editor/plugin/font/ui",
"editor/plugin/underline/cmd"]},"editor/plugin/maximize/cmd":{requires:["editor"]},"editor/plugin/contextmenu/index":{requires:["editor","menu","editor/plugin/focus-fix/"]},"editor/plugin/heading/index":{requires:["editor","editor/plugin/heading/cmd"]},"editor/plugin/drag-upload/index":{requires:["editor"]},"editor/plugin/color/cmd":{requires:["editor"]},"editor/plugin/code/index":{requires:["editor","editor/plugin/dialog-loader/"]},"editor/plugin/flash/dialog":{requires:["editor","editor/plugin/flash-common/utils",
"editor/plugin/overlay/","editor/plugin/menubutton/"]},"editor/plugin/strike-through/cmd":{requires:["editor","editor/plugin/font/cmd"]},"editor/plugin/unordered-list/index":{requires:["editor","editor/plugin/list-utils/btn","editor/plugin/unordered-list/cmd"]},"editor/plugin/outdent/cmd":{requires:["editor","editor/plugin/dent-utils/cmd"]},"editor/plugin/italic/index":{requires:["editor","editor/plugin/font/ui","editor/plugin/italic/cmd"]},"editor/plugin/remove-format/cmd":{requires:["editor"]},
"editor/plugin/font-size/index":{requires:["editor","editor/plugin/font/ui","editor/plugin/font-size/cmd"]},"editor/plugin/indent/cmd":{requires:["editor","editor/plugin/dent-utils/cmd"]},"editor/plugin/table/index":{requires:["editor","editor/plugin/dialog-loader/","editor/plugin/contextmenu/"]},"editor/plugin/word-filter/dynamic/index":{requires:["htmlparser"]},"editor/plugin/justify-left/cmd":{requires:["editor/plugin/justify-utils/cmd"]},"editor/plugin/resize/index":{requires:["editor","dd/base"]},
"editor/plugin/video/dialog":{requires:["editor","editor/plugin/flash/dialog","editor/plugin/menubutton/"]},"editor/plugin/focus-fix/index":{requires:["editor"]},"editor/plugin/xiami-music/index":{requires:["editor","editor/plugin/flash-common/baseClass","editor/plugin/flash-common/utils","editor/plugin/fake-objects/"]},"editor/plugin/maximize/index":{requires:["editor","editor/plugin/maximize/cmd"]},"editor/plugin/color/color-picker/dialog":{requires:["editor","editor/plugin/overlay/"]},"editor/plugin/smiley/index":{requires:["editor",
"editor/plugin/overlay/"]},"editor/plugin/separator/index":{requires:["editor"]},"editor/plugin/video/index":{requires:["editor","editor/plugin/flash-common/utils","editor/plugin/flash-common/baseClass","editor/plugin/fake-objects/"]},"editor/plugin/multiple-upload/index":{requires:["editor","editor/plugin/dialog-loader/"]},"editor/plugin/undo/btn":{requires:["editor","editor/plugin/button/"]},"editor/plugin/menubutton/index":{requires:["editor","menubutton"]},"editor/plugin/flash/index":{requires:["editor",
"editor/plugin/flash-common/baseClass","editor/plugin/flash-common/utils","editor/plugin/fake-objects/"]},"editor/plugin/overlay/index":{requires:["editor","overlay","editor/plugin/focus-fix/","dd/plugin/constrain","component/plugin/drag"]},"editor/plugin/link/utils":{requires:["editor"]},"editor/plugin/xiami-music/dialog":{requires:["editor","editor/plugin/flash/dialog","editor/plugin/menubutton/"]},"editor/plugin/list-utils/cmd":{requires:["editor","editor/plugin/list-utils/"]},"editor/plugin/button/index":{requires:["editor",
"button"]},"editor/plugin/checkbox-source-area/index":{requires:["editor"]},"editor/plugin/strike-through/index":{requires:["editor","editor/plugin/font/ui","editor/plugin/strike-through/cmd"]},"editor/plugin/fore-color/index":{requires:["editor","editor/plugin/color/btn","editor/plugin/fore-color/cmd"]},"editor/plugin/flash-bridge/index":{requires:["swf","editor"]},"editor/plugin/fore-color/cmd":{requires:["editor/plugin/color/cmd"]},"editor/plugin/table/dialog":{requires:["editor","editor/plugin/overlay/",
"editor/plugin/menubutton/"]},"editor/plugin/justify-utils/cmd":{requires:["editor"]},"editor/plugin/undo/index":{requires:["editor","editor/plugin/undo/btn","editor/plugin/undo/cmd"]},"editor/plugin/justify-right/cmd":{requires:["editor/plugin/justify-utils/cmd"]},"editor/plugin/image/index":{requires:["editor","editor/plugin/button/","editor/plugin/bubble/","editor/plugin/contextmenu/","editor/plugin/dialog-loader/"]},"editor/plugin/dent-utils/cmd":{requires:["editor","editor/plugin/list-utils/"]},
"editor/plugin/ordered-list/cmd":{requires:["editor","editor/plugin/list-utils/cmd"]},"editor/plugin/list-utils/index":{requires:["editor"]},"editor/plugin/dialog-loader/index":{requires:["overlay","editor"]},"editor/plugin/flash-common/utils":{requires:["swf"]},"editor/plugin/font-family/index":{requires:["editor","editor/plugin/font/ui","editor/plugin/font-family/cmd"]},"editor/plugin/undo/cmd":{requires:["editor"]},"editor/plugin/indent/index":{requires:["editor","editor/plugin/indent/cmd"]},"editor/plugin/font/cmd":{requires:["editor"]},
"editor/plugin/ordered-list/index":{requires:["editor","editor/plugin/list-utils/btn","editor/plugin/ordered-list/cmd"]},"editor/plugin/color/btn":{requires:["editor","editor/plugin/button/","editor/plugin/overlay/","editor/plugin/dialog-loader/"]},"editor/plugin/bold/cmd":{requires:["editor","editor/plugin/font/cmd"]},"editor/plugin/local-storage/index":{requires:["editor","overlay","editor/plugin/flash-bridge/"]},"editor/plugin/bubble/index":{requires:["overlay","editor"]},"editor/plugin/underline/cmd":{requires:["editor",
"editor/plugin/font/cmd"]},"editor/plugin/bold/index":{requires:["editor","editor/plugin/font/ui","editor/plugin/bold/cmd"]},"editor/plugin/back-color/index":{requires:["editor","editor/plugin/color/btn","editor/plugin/back-color/cmd"]},"editor/plugin/draft/index":{requires:["editor","editor/plugin/local-storage/","overlay","editor/plugin/menubutton/"]},"editor/plugin/link/index":{requires:["editor","editor/plugin/bubble/","editor/plugin/link/utils","editor/plugin/dialog-loader/","editor/plugin/button/"]},
"editor/plugin/remove-format/index":{requires:["editor","editor/plugin/remove-format/cmd","editor/plugin/button/"]},"editor/plugin/font/ui":{requires:["editor","editor/plugin/button/","editor/plugin/menubutton/"]},"editor/plugin/element-path/index":{requires:["editor"]},"editor/plugin/source-area/index":{requires:["editor","editor/plugin/button/"]},"editor/plugin/justify-right/index":{requires:["editor","editor/plugin/justify-right/cmd"]},"editor/plugin/list-utils/btn":{requires:["editor","editor/plugin/button/",
"editor/plugin/menubutton/"]},"editor/plugin/justify-left/index":{requires:["editor","editor/plugin/justify-left/cmd"]},"editor/plugin/outdent/index":{requires:["editor","editor/plugin/outdent/cmd"]},"editor/plugin/fake-objects/index":{requires:["editor"]},"editor/plugin/font-family/cmd":{requires:["editor","editor/plugin/font/cmd"]},"editor/plugin/back-color/cmd":{requires:["editor/plugin/color/cmd"]},"editor/plugin/link/dialog":{requires:["editor","editor/plugin/overlay/","editor/plugin/link/utils"]},
"editor/plugin/multiple-upload/dialog":{requires:"editor,component/plugin/drag,editor/plugin/progressbar/,editor/plugin/overlay/,editor/plugin/flash-bridge/,editor/plugin/local-storage/,swf".split(",")},"editor/plugin/code/dialog":{requires:["editor","editor/plugin/overlay/","menubutton"]},"editor/plugin/justify-center/cmd":{requires:["editor/plugin/justify-utils/cmd"]},"editor/plugin/flash-common/baseClass":{requires:["editor","editor/plugin/contextmenu/","editor/plugin/bubble/","editor/plugin/dialog-loader/",
"editor/plugin/flash-common/utils"]},"editor/plugin/justify-center/index":{requires:["editor","editor/plugin/justify-center/cmd"]},"editor/plugin/unordered-list/cmd":{requires:["editor","editor/plugin/list-utils/cmd"]}});
KISSY.add("editor/core/range",function(e,h,p,r,m){function v(b){var c=b.nodeType!=d.NodeType.TEXT_NODE&&d.nodeName(b)in a.$removeEmpty,i=b.nodeType==d.NodeType.TEXT_NODE&&!e.trim(b.nodeValue),b=!!b.parentNode.getAttribute("_ke_bookmark");return c||i||b}function b(a){return!B(a)&&!C(a)}function k(a){var b=w;return function(c){if(C(c))return j;if(c.nodeType==d.NodeType.TEXT_NODE){if(e.trim(c.nodeValue).length)return w}else if(c.nodeType==d.NodeType.ELEMENT_NODE&&(c=d.nodeName(c),!G[c]))if(!a&&!t.ie&&
"br"==c&&!b)b=j;else return w;return j}}function o(a,b){var c=a.startContainer,g=a.endContainer,f=a.startOffset,e=a.endOffset,s,k=w,h=w,o=void 0,n=a.document,P;0<b&&(o=n.createDocumentFragment());if(a.collapsed)return o;a.optimizeBookmark();g[0].nodeType==d.NodeType.TEXT_NODE?(h=j,g=g._4e_splitText(e)):0<g[0].childNodes.length&&(e>=g[0].childNodes.length?(g=new i(g[0].appendChild(n.createTextNode(""))),P=j):g=new i(g[0].childNodes[e]));c[0].nodeType==d.NodeType.TEXT_NODE?(k=j,c._4e_splitText(f)):
f?f>=c[0].childNodes.length?(c=new i(c[0].appendChild(n.createTextNode(""))),s=j):c=new i(c[0].childNodes[f].previousSibling):(s=new i(n.createTextNode("")),c.prepend(s),c=s,s=j);var H=c._4e_parents(),K=g._4e_parents();H.each(function(a,d){H[d]=a});K.each(function(a,d){K[d]=a});for(var E,N,n=0;n<H.length&&!(E=H[n],N=K[n],!E.equals(N));n++);for(var f=o,A,J,B=n;B<H.length;B++){A=H[B];e=0<b&&!A.equals(c)?f.appendChild(A.clone()[0]):null;A=A[0].nextSibling;J=K[B];for(var m=g[0],t=J&&J[0];A&&!(t==A||m==
A);){J=A.nextSibling;if(2==b)f.appendChild(A.cloneNode(j));else{if(l[A.nodeName.toLowerCase()]){var p=A.cloneNode(j);A.innerHTML="";A=p}else d._4e_remove(A);1==b&&f.appendChild(A)}A=J}e&&(f=e)}for(f=o;n<K.length;n++){A=K[n];e=0<b&&!A.equals(g)?f.appendChild(A.clone()[0]):null;if(!H[n]||!A._4e_sameLevel(H[n]))for(A=A[0].previousSibling;A;)J=A.previousSibling,2==b?f.insertBefore(A.cloneNode(j),f.firstChild):(d._4e_remove(A),1==b&&f.insertBefore(A,f.firstChild)),A=J;e&&(f=e)}if(2==b){if(k&&(E=c[0],E.nodeType==
d.NodeType.TEXT_NODE&&E.nextSibling&&E.nextSibling.nodeType==d.NodeType.TEXT_NODE&&(E.data+=E.nextSibling.data,E.parentNode.removeChild(E.nextSibling))),h)h=g[0],h.nodeType==d.NodeType.TEXT_NODE&&h.previousSibling&&h.previousSibling.nodeType==d.NodeType.TEXT_NODE&&(h.previousSibling.data+=h.data,h.parentNode.removeChild(h))}else{if(E&&N&&(!c._4e_sameLevel(E)||!g._4e_sameLevel(N)))h=E._4e_index(),s&&E._4e_sameLevel(c)&&h--,a.setStart(E.parent(),h+1);a.collapse(j)}s&&c.remove();P&&g.remove();return o}
function n(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=y;this.collapsed=j;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 j=!0,w=!1,y=null,f=h.RANGE,c=h.POSITION,
d=e.DOM,t=e.UA,a=h.XHTML_DTD,i=e.Node,g=i.all,l={td:1},s={area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},B=new r.whitespaces,C=new r.bookmark,z=r.whitespaces(j),D=r.bookmark(!1,!0),G={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};e.augment(u,{toString:function(){var a=[],d=this.startContainer[0],b=this.endContainer[0];a.push((d.id||d.nodeName)+":"+this.startOffset);
a.push((b.id||b.nodeName)+":"+this.endOffset);return a.join("<br/>")},optimize:function(){var a=this.startContainer,b=this.startOffset;a[0].nodeType!=d.NodeType.ELEMENT_NODE&&(b?b>=a[0].nodeValue.length&&this.setStartAfter(a):this.setStartBefore(a));a=this.endContainer;b=this.endOffset;a[0].nodeType!=d.NodeType.ELEMENT_NODE&&(b?b>=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,d=this.endContainer;a&&"span"==a.nodeName()&&a.attr("_ke_bookmark")&&this.setStartBefore(a);d&&"span"==d.nodeName()&&d.attr("_ke_bookmark")&&this.setEndAfter(d)},setStart:function(a,b){a[0].nodeType==d.NodeType.ELEMENT_NODE&&s[a.nodeName()]&&(a=a.parent(),b=a._4e_index());this.startContainer=a;this.startOffset=
b;this.endContainer||(this.endContainer=a,this.endOffset=b);n(this)},setEnd:function(a,b){a[0].nodeType==d.NodeType.ELEMENT_NODE&&s[a.nodeName()]&&(a=a.parent(),b=a._4e_index()+1);this.endContainer=a;this.endOffset=b;this.startContainer||(this.startContainer=a,this.startOffset=b);n(this)},setStartAt:function(a,b){switch(b){case f.POSITION_AFTER_START:this.setStart(a,0);break;case f.POSITION_BEFORE_END:a[0].nodeType==d.NodeType.TEXT_NODE?this.setStart(a,a[0].nodeValue.length):this.setStart(a,a[0].childNodes.length);
break;case f.POSITION_BEFORE_START:this.setStartBefore(a);break;case f.POSITION_AFTER_END:this.setStartAfter(a)}n(this)},setEndAt:function(a,b){switch(b){case f.POSITION_AFTER_START:this.setEnd(a,0);break;case f.POSITION_BEFORE_END:a[0].nodeType==d.NodeType.TEXT_NODE?this.setEnd(a,a[0].nodeValue.length):this.setEnd(a,a[0].childNodes.length);break;case f.POSITION_BEFORE_START:this.setEndBefore(a);break;case f.POSITION_AFTER_END:this.setEndAfter(a)}n(this)},cloneContents:function(){return o(this,2)},
deleteContents:function(){return o(this,0)},extractContents:function(){return o(this,1)},collapse:function(a){a?(this.endContainer=this.startContainer,this.endOffset=this.startOffset):(this.startContainer=this.endContainer,this.startOffset=this.endOffset);this.collapsed=j},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!=d.NodeType.ELEMENT_NODE||a.endContainer[0].nodeType!=d.NodeType.ELEMENT_NODE)return y;var b=new r(a);b.evaluator=function(a){return z(a)&&D(a)};a=b.next();b.reset();b=b.previous();return a&&a.equals(b)?a:y},shrink:function(a,b){if(!this.collapsed){var a=a||f.SHRINK_TEXT,c=this.clone(),g=this.startContainer,i=this.endContainer,e=this.startOffset,l=this.endOffset,s=j,k,h,o=j;g&&g[0].nodeType==d.NodeType.TEXT_NODE&&(e?e>=g[0].nodeValue.length?
c.setStartAfter(g):(c.setStartBefore(g),s=w):c.setStartBefore(g));i&&i[0].nodeType==d.NodeType.TEXT_NODE&&(l?l>=i[0].nodeValue.length?c.setEndAfter(i):(c.setEndAfter(i),o=w):c.setEndBefore(i));if(s||o)h=new r(c),h.evaluator=function(b){return b.nodeType==(a==f.SHRINK_ELEMENT?d.NodeType.ELEMENT_NODE:d.NodeType.TEXT_NODE)},h.guard=function(b,c){if(a==f.SHRINK_ELEMENT&&b.nodeType==d.NodeType.TEXT_NODE||c&&b==k)return w;!c&&b.nodeType==d.NodeType.ELEMENT_NODE&&(k=b);return j};s&&(c=h[a==f.SHRINK_ELEMENT?
"lastForward":"next"]())&&this.setStartAt(c,b?f.POSITION_AFTER_START:f.POSITION_BEFORE_START);o&&(h.reset(),(h=h[a==f.SHRINK_ELEMENT?"lastBackward":"previous"]())&&this.setEndAt(h,b?f.POSITION_BEFORE_END:f.POSITION_AFTER_END));return s||o}},createBookmark2:function(a){var b=this.startContainer,c=this.endContainer,g=this.startOffset,f=this.endOffset,e,l;if(!b||!c)return{start:0,end:0};if(a){if(b[0].nodeType==d.NodeType.ELEMENT_NODE&&(e=new i(b[0].childNodes[g]))&&e[0]&&e[0].nodeType==d.NodeType.TEXT_NODE&&
0<g&&e[0].previousSibling.nodeType==d.NodeType.TEXT_NODE)b=e,g=0;for(;b[0].nodeType==d.NodeType.TEXT_NODE&&(l=b.prev(void 0,1))&&l[0].nodeType==d.NodeType.TEXT_NODE;)b=l,g+=l[0].nodeValue.length;if(!this.collapsed){if(c[0].nodeType==d.NodeType.ELEMENT_NODE&&(e=new i(c[0].childNodes[f]))&&e[0]&&e[0].nodeType==d.NodeType.TEXT_NODE&&0<f&&e[0].previousSibling.nodeType==d.NodeType.TEXT_NODE)c=e,f=0;for(;c[0].nodeType==d.NodeType.TEXT_NODE&&(l=c.prev(void 0,1))&&l[0].nodeType==d.NodeType.TEXT_NODE;)c=l,
f+=l[0].nodeValue.length}}return{start:b._4e_address(a),end:this.collapsed?y:c._4e_address(a),startOffset:g,endOffset:f,normalized:a,is2:j}},createBookmark:function(a){var b,d,c,g,l=this.collapsed;b=new i("<span>",y,this.document);b.attr("_ke_bookmark",1);b.css("display","none");b.html("&nbsp;");a&&(c=e.guid("ke_bm_"),b.attr("id",c+"S"));l||(d=b.clone(),d.html("&nbsp;"),a&&d.attr("id",c+"E"),g=this.clone(),g.collapse(),g.insertNode(d));g=this.clone();g.collapse(j);g.insertNode(b);d?(this.setStartAfter(b),
this.setEndBefore(d)):this.moveToPosition(b,f.POSITION_AFTER_END);return{startNode:a?c+"S":b,endNode:a?c+"E":d,serializable:a,collapsed:l}},moveToPosition:function(a,b){this.setStartAt(a,b);this.collapse(j)},trim:function(a,b){var c=this.startContainer,g=this.startOffset,i=this.collapsed;if((!a||i)&&c[0]&&c[0].nodeType==d.NodeType.TEXT_NODE){if(g)if(g>=c[0].nodeValue.length)g=c._4e_index()+1,c=c.parent();else{var f=c._4e_splitText(g),g=c._4e_index()+1,c=c.parent();d.equals(this.startContainer,this.endContainer)?
this.setEnd(f,this.endOffset-this.startOffset):d.equals(c,this.endContainer)&&(this.endOffset+=1)}else g=c._4e_index(),c=c.parent();this.setStart(c,g);if(i){this.collapse(j);return}}c=this.endContainer;g=this.endOffset;!b&&!i&&c[0]&&c[0].nodeType==d.NodeType.TEXT_NODE&&(g?(g>=c[0].nodeValue.length||c._4e_splitText(g),g=c._4e_index()+1):g=c._4e_index(),c=c.parent(),this.setEnd(c,g))},insertNode:function(a){this.optimizeBookmark();this.trim(w,j);var b=this.startContainer;b[0].insertBefore(a[0],b[0].childNodes[this.startOffset]||
null);b[0]==this.endContainer[0]&&this.endOffset++;this.setStartBefore(a)},moveToBookmark:function(a){var b=g(this.document);if(a.is2){var d=b._4e_getByAddress(a.start,a.normalized),c=a.startOffset,b=a.end&&b._4e_getByAddress(a.end,a.normalized),a=a.endOffset;this.setStart(d,c);b?this.setEnd(b,a):this.collapse(j)}else d=(c=a.serializable)?e.one("#"+a.startNode,b):a.startNode,a=c?e.one("#"+a.endNode,b):a.endNode,this.setStartBefore(d),d._4e_remove(),a&&a[0]?(this.setEndBefore(a),a._4e_remove()):this.collapse(j)},
getCommonAncestor:function(a,b){var c=this.startContainer,g=this.endContainer,c=c[0]==g[0]?a&&c[0].nodeType==d.NodeType.ELEMENT_NODE&&this.startOffset==this.endOffset-1?new i(c[0].childNodes[this.startOffset]):c:c._4e_commonAncestor(g);return b&&c[0].nodeType==d.NodeType.TEXT_NODE?c.parent():c},enlarge:function(){function a(b,c,i,f){var e=b[c?"startContainer":"endContainer"],l,s=c?0:1,k=0,q=c?"previousSibling":"nextSibling";l=b[c?"startOffset":"endOffset"];if(e[0].nodeType==d.NodeType.TEXT_NODE){if(c){if(l)return}else if(l<
e[0].nodeValue.length)return;l=e[0][q];e=e[0].parentNode}else l=e[0].childNodes[l+(c?-1:1)]||null,e=e[0];for(;e;){for(;l;)if(B(l)||C(l))l=l[q];else break;if(l){if(!k)b[c?"setStartAfter":"setEndBefore"](g(l));break}e=g(e);if("body"==e.nodeName())break;if(k||e.equals(f))i[s]=e,k=1;else b[c?"setStartBefore":"setEndAfter"](e);l=e[0][q];e=e[0].parentNode}}return function(b){switch(b){case f.ENLARGE_ELEMENT:if(this.collapsed)break;var b=this.getCommonAncestor(),c=[];a(this,1,c,b);a(this,0,c,b);c[0]&&c[1]&&
(b=c[0].contains(c[1])?c[1]:c[0],this.setStartBefore(b),this.setEndAfter(b));break;case f.ENLARGE_BLOCK_CONTENTS:case f.ENLARGE_LIST_ITEM_CONTENTS:var e=new u(this.document),c=new i(this.document.body);e.setStartAt(c,f.POSITION_AFTER_START);e.setEnd(this.startContainer,this.startOffset);var e=new r(e),l,s,k=r.blockBoundary(b==f.ENLARGE_LIST_ITEM_CONTENTS?{br:1}:y),j=function(a){var b=k(a);b||(l=g(a));return b},h=function(a){var b=j(a);!b&&"br"==d.nodeName(a)&&(s=g(a));return b};e.guard=j;e=e.lastBackward();
l=l||c;this.setStartAt(l,"br"!=l.nodeName()&&(!e&&this.checkStartOfBlock()||e&&l.contains(e))?f.POSITION_AFTER_START:f.POSITION_AFTER_END);e=this.clone();e.collapse();e.setEndAt(c,f.POSITION_BEFORE_END);e=new r(e);e.guard=b==f.ENLARGE_LIST_ITEM_CONTENTS?h:j;l=y;e=e.lastForward();l=l||c;this.setEndAt(l,!e&&this.checkEndOfBlock()||e&&l.contains(e)?f.POSITION_BEFORE_END:f.POSITION_BEFORE_START);s&&this.setEndAfter(s)}}}(),checkStartOfBlock:function(){var a=this.startContainer,b=this.startOffset;if(b&&
a[0].nodeType==d.NodeType.TEXT_NODE&&e.trim(a[0].nodeValue.substring(0,b)).length)return w;this.trim();a=new m(this.startContainer);b=this.clone();b.collapse(j);b.setStartAt(a.block||a.blockLimit,f.POSITION_AFTER_START);a=new r(b);a.evaluator=k(j);return a.checkBackward()},checkEndOfBlock:function(){var a=this.endContainer,b=this.endOffset;if(a[0].nodeType==d.NodeType.TEXT_NODE&&e.trim(a[0].nodeValue.substring(b)).length)return w;this.trim();a=new m(this.endContainer);b=this.clone();b.collapse(w);
b.setEndAt(a.block||a.blockLimit,f.POSITION_BEFORE_END);a=new r(b);a.evaluator=k(w);return a.checkForward()},checkBoundaryOfElement:function(a,b){var c=this.clone();c[b==f.START?"setStartAt":"setEndAt"](a,b==f.START?f.POSITION_AFTER_START:f.POSITION_BEFORE_END);c=new r(c);c.evaluator=v;return c[b==f.START?"checkBackward":"checkForward"]()},getBoundaryNodes:function(){var a=this.startContainer,b=this.endContainer,i=this.startOffset,e=this.endOffset,f;if(a[0].nodeType==d.NodeType.ELEMENT_NODE)if(f=
a[0].childNodes.length,f>i)a=g(a[0].childNodes[i]);else if(0==f)a=a._4e_previousSourceNode();else{for(a=a[0];a.lastChild;)a=a.lastChild;a=g(a);a=a._4e_nextSourceNode()||a}if(b[0].nodeType==d.NodeType.ELEMENT_NODE)if(f=b[0].childNodes.length,f>e)b=g(b[0].childNodes[e])._4e_previousSourceNode(j);else if(0==f)b=b._4e_previousSourceNode();else{for(b=b[0];b.lastChild;)b=b.lastChild;b=g(b)}a._4e_position(b)&c.POSITION_FOLLOWING&&(a=b);return{startNode:a,endNode:b}},fixBlock:function(a,b){var c=this.createBookmark(),
d=g(this.document.createElement(b));this.collapse(a);this.enlarge(f.ENLARGE_BLOCK_CONTENTS);d[0].appendChild(this.extractContents());d._4e_trim();t.ie||d._4e_appendBogus();this.insertNode(d);this.moveToBookmark(c);return d},splitBlock:function(a){var b=new m(this.startContainer),c=new m(this.endContainer),d=b.block,g=c.block,i=y;if(!b.blockLimit.equals(c.blockLimit))return y;"br"!=a&&(d||(d=this.fixBlock(j,a),g=(new m(this.endContainer)).block),g||(g=this.fixBlock(w,a)));a=d&&this.checkStartOfBlock();
b=g&&this.checkEndOfBlock();this.deleteContents();d&&d[0]==g[0]&&(b?(i=new m(this.startContainer),this.moveToPosition(g,f.POSITION_AFTER_END),g=y):a?(i=new m(this.startContainer),this.moveToPosition(d,f.POSITION_BEFORE_START),d=y):(g=this.splitElement(d),!t.ie&&!e.inArray(d.nodeName(),["ul","ol"])&&d._4e_appendBogus()));return{previousBlock:d,nextBlock:g,wasStartOfBlock:a,wasEndOfBlock:b,elementPath:i}},splitElement:function(a){if(!this.collapsed)return y;this.setEndAt(a,f.POSITION_BEFORE_END);var b=
this.extractContents(),c=a.clone(w);c[0].appendChild(b);c.insertAfter(a);this.moveToPosition(a,f.POSITION_AFTER_END);return c},moveToElementEditablePosition:function(a,c){for(var g=0;a;){if(a[0].nodeType==d.NodeType.TEXT_NODE){this.moveToPosition(a,c?f.POSITION_AFTER_END:f.POSITION_BEFORE_START);g=1;break}a[0].nodeType==d.NodeType.ELEMENT_NODE&&a._4e_isEditable()&&(this.moveToPosition(a,c?f.POSITION_BEFORE_END:f.POSITION_AFTER_START),g=1);var i=a,e=g,l=void 0;i[0].nodeType==d.NodeType.ELEMENT_NODE&&
i._4e_isEditable()&&(l=i[c?"last":"first"](b,1));!e&&!l&&(l=i[c?"prev":"next"](b,1));a=l}return!!g},selectNodeContents:function(a){var b=a[0];this.setStart(a,0);this.setEnd(a,b.nodeType==d.NodeType.TEXT_NODE?b.nodeValue.length:b.childNodes.length)},insertNodeByDtd:function(b){var c,d,g,i=b.nodeName();c=a.$block[i];this.deleteContents();if(c){for(c=this.getCommonAncestor(w,j);(d=a[c.nodeName()])&&(!d||!d[i]);){var e=c.parent();this.checkStartOfBlock()&&this.checkEndOfBlock()?(this.setStartBefore(c),
this.collapse(j),c.remove()):g=c;c=e}g&&this.splitElement(g)}this.insertNode(b)}});p.injectDom({_4e_breakParent:function(a,b){var b=g(b),a=g(a),c,d=new h.Range(a[0].ownerDocument);d.setStartAfter(a);d.setEndAfter(b);c=d.extractContents();d.insertNode(a.remove());a.after(c)}});return h.Range=u},{requires:"./base,./utils,./walker,./elementPath,./dom,node".split(",")});
KISSY.add("editor/core/selection",function(e,h){function p(a){this.document=a;this._={cache:{}};if(j)try{var b=this.getNative().createRange();if(!b||b.item&&b.item(0).ownerDocument!=a||b.parentElement&&b.parentElement().ownerDocument!=a)this.isInvalid=m}catch(c){this.isInvalid=m}}function r(a){a=new p(a);return!a||a.isInvalid?v:a}h.SELECTION={SELECTION_NONE:1,SELECTION_TEXT:2,SELECTION_ELEMENT:3};var m=!0,v=null,b=e.UA,k=e.DOM,o=e.Node,n=h.SELECTION,u=h.RANGE,j=b.ie,w=h.Walker,y=h.Range,f={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};e.augment(p,{getNative:!j?function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=k.getWindow(this.document).getSelection())}:function(){var a=this._.cache;return a.nativeSel||(a.nativeSel=this.document.selection)},getType:!j?function(){var a=this._.cache;if(a.type)return a.type;var b=n.SELECTION_TEXT,c=this.getNative();if(c){if(1==c.rangeCount){var c=c.getRangeAt(0),
d=c.startContainer;d==c.endContainer&&d.nodeType==k.NodeType.ELEMENT_NODE&&1==Number(c.endOffset-c.startOffset)&&f[d.childNodes[c.startOffset].nodeName.toLowerCase()]&&(b=n.SELECTION_ELEMENT)}}else b=n.SELECTION_NONE;return a.type=b}:function(){var a=this._.cache;if(a.type)return a.type;var b=n.SELECTION_NONE;try{var c=this.getNative(),d=c.type;"Text"==d&&(b=n.SELECTION_TEXT);"Control"==d&&(b=n.SELECTION_ELEMENT);c.createRange().parentElement&&(b=n.SELECTION_TEXT)}catch(e){}return a.type=b},getRanges:j?
function(){var a=function(a,b){a=a.duplicate();a.collapse(b);for(var c=a.parentElement(),d=c.childNodes,e,f=0;f<d.length;f++){var j=d[f];if(j.nodeType==k.NodeType.ELEMENT_NODE){e=a.duplicate();e.moveToElementText(j);var j=e.compareEndPoints("StartToStart",a),h=e.compareEndPoints("EndToStart",a);e.collapse();if(0<j)break;else{if(!j||1==h&&-1==j)return{container:c,offset:f};if(!h)return{container:c,offset:f+1}}e=v}}e||(e=a.duplicate(),e.moveToElementText(c),e.collapse(!1));e.setEndPoint("StartToStart",
a);e=(""+e.text).replace(/\r\n|\r/g,"\n").length;try{for(;0<e;)e-=d[--f].nodeValue.length}catch(o){e=0}return 0===e?{container:c,offset:f}:{container:d[f],offset:-e}};return function(b){var c=this._.cache;if(c.ranges&&!b)return c.ranges;var d=this.getNative(),b=d&&d.createRange(),e=this.getType();if(!d)return[];if(e==n.SELECTION_TEXT)return d=new y(this.document),e=a(b,m),d.setStart(new o(e.container),e.offset),e=a(b),d.setEnd(new o(e.container),e.offset),c.ranges=[d];if(e==n.SELECTION_ELEMENT){c=
c.ranges=[];for(e=0;e<b.length;e++){for(var f=b.item(e),k=f.parentNode,j=0,d=new y(this.document);j<k.childNodes.length&&k.childNodes[j]!=f;j++);d.setStart(new o(k),j);d.setEnd(new o(k),j+1);c.push(d)}return c}return c.ranges=[]}}():function(a){var b=this._.cache;if(b.ranges&&!a)return b.ranges;var a=[],c=this.getNative();if(!c)return[];for(var d=0;d<c.rangeCount;d++){var e=c.getRangeAt(d),f=new y(this.document);f.setStart(new o(e.startContainer),e.startOffset);f.setEnd(new o(e.endContainer),e.endOffset);
a.push(f)}return b.ranges=a},getStartElement:function(){var a=this._.cache;if(void 0!==a.startElement)return a.startElement;var b,c=this.getNative();switch(this.getType()){case n.SELECTION_ELEMENT:return this.getSelectedElement();case n.SELECTION_TEXT:var d=this.getRanges()[0];if(d&&!d.collapsed){for(d.optimize();m;)if(b=d.startContainer,d.startOffset==(b[0].nodeType===k.NodeType.ELEMENT_NODE?b[0].childNodes.length:b[0].nodeValue.length)&&!b._4e_isBlockBoundary())d.setStartAfter(b);else break;b=d.startContainer;
if(b[0].nodeType!=k.NodeType.ELEMENT_NODE)return b.parent();b=new o(b[0].childNodes[d.startOffset]);if(!b[0]||b[0].nodeType!=k.NodeType.ELEMENT_NODE)return d.startContainer;for(d=b[0].firstChild;d&&d.nodeType==k.NodeType.ELEMENT_NODE;)b=new o(d),d=d.firstChild;return b}if(j)d=c.createRange(),d.collapse(m),b=new o(d.parentElement());else{if((b=c.anchorNode)&&b.nodeType!=k.NodeType.ELEMENT_NODE)b=b.parentNode;b&&(b=new o(b))}}return a.startElement=b},getSelectedElement:function(){var a,b=this._.cache;
if(void 0!==b.selectedElement)return b.selectedElement;j&&(a=this.getNative().createRange(),a=a.item&&a.item(0));var c;if(a)c=new o(a);else{a=this.getRanges()[0];for(var d,e=2;e&&(!(c=a.getEnclosedNode())||!(c[0].nodeType==k.NodeType.ELEMENT_NODE&&f[c.nodeName()]&&(d=c)));e--)a.shrink(u.SHRINK_ELEMENT);c=d}return b.selectedElement=c},reset:function(){this._.cache={}},selectElement:function(a){var b,c=this.document;if(j)try{b=c.body.createControlRange(),b.addElement(a[0]),b.select()}catch(d){b=c.body.createTextRange(),
b.moveToElementText(a[0]),b.select()}finally{}else b=c.createRange(),b.selectNode(a[0]),a=this.getNative(),a.removeAllRanges(),a.addRange(b);this.reset()},selectRanges:function(a){if(j){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 d=0;d<a.length;d++){var e=a[d],f=this.document.createRange(),h=e.startContainer;if(e.collapsed&&(b.gecko&&1.09>b.gecko||b.opera||b.webkit)&&h[0].nodeType==
k.NodeType.ELEMENT_NODE&&!h[0].childNodes.length)h[0].appendChild(this.document.createTextNode(b.webkit?"\u200b":"")),e.startOffset++,e.endOffset++;f.setStart(h[0],e.startOffset);f.setEnd(e.endContainer[0],e.endOffset);c.addRange(f)}}this.reset()},createBookmarks2:function(a){for(var b=[],c=this.getRanges(),d=0;d<c.length;d++)b.push(c[d].createBookmark2(a));return b},createBookmarks:function(a,b){for(var c=[],d=this.document,f,b=b||this.getRanges(),j=b.length,h=0;h<j;h++){c.push(f=b[h].createBookmark(a,
m));var o=(a=f.serializable)?e.one("#"+f.startNode,d):f.startNode;f=a?e.one("#"+f.endNode,d):f.endNode;for(var n=h+1;n<j;n++){var t=b[n],p=t.startContainer,r=t.endContainer;k.equals(p,o.parent())&&t.startOffset++;k.equals(p,f.parent())&&t.startOffset++;k.equals(r,o.parent())&&t.endOffset++;k.equals(r,f.parent())&&t.endOffset++}}return c},selectBookmarks:function(a){for(var b=[],c=0;c<a.length;c++){var d=new y(this.document);d.moveToBookmark(a[c]);b.push(d)}this.selectRanges(b);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,{alignWithTop:!1,allowHorizontalScroll:!0,onlyScrollIfNeeded:!0})},removeAllRanges:function(){var a=this.getNative();j?a&&a.clear():a&&a.removeAllRanges()}});var c={table:1,tbody:1,tr:1},d=w.whitespaces(m),t=/\ufeff|\u00a0/;y.prototype.select=y.prototype.select=!j?function(){var a=this.startContainer;this.collapsed&&a[0].nodeType==
k.NodeType.ELEMENT_NODE&&!a[0].childNodes.length&&(a[0].appendChild(this.document.createTextNode(b.webkit?"\u200b":"")),this.startOffset++,this.endOffset++);var c=this.document.createRange();c.setStart(a[0],this.startOffset);try{c.setEnd(this.endContainer[0],this.endOffset)}catch(d){if(0<=d.toString().indexOf("NS_ERROR_ILLEGAL_VALUE"))this.collapse(m),c.setEnd(this.endContainer[0],this.endOffset);else throw d;}a=r(this.document).getNative();a.removeAllRanges();a.addRange(c)}:function(a){var b=this.collapsed,
e,f;if(this.startContainer[0]===this.endContainer[0]&&1==this.endOffset-this.startOffset){var j=this.startContainer[0].childNodes[this.startOffset];if(j.nodeType==k.NodeType.ELEMENT_NODE){(new p(this.document)).selectElement(new o(j));return}}(this.startContainer[0].nodeType==k.NodeType.ELEMENT_NODE&&this.startContainer.nodeName()in c||this.endContainer[0].nodeType==k.NodeType.ELEMENT_NODE&&this.endContainer.nodeName()in c)&&this.shrink(u.SHRINK_ELEMENT,m);var h=this.createBookmark(),j=h.startNode,
n;b||(n=h.endNode);h=this.document.body.createTextRange();h.moveToElementText(j[0]);h.moveStart("character",1);if(n)a=this.document.body.createTextRange(),a.moveToElementText(n[0]),h.setEndPoint("EndToEnd",a),h.moveEnd("character",-1);else{for(e=j[0].nextSibling;e&&!d(e);)e=e.nextSibling;e=!(e&&e.nodeValue&&e.nodeValue.match(t))&&(a||!j[0].previousSibling||j[0].previousSibling&&"br"==k.nodeName(j[0].previousSibling));f=new o(this.document.createElement("span"));f.html("&#65279;");f.insertBefore(j);
e&&k.insertBefore(this.document.createTextNode("\ufeff"),j[0]||j)}this.setStartBefore(j);j._4e_remove();if(b){if(e?(h.moveStart("character",-1),h.select(),this.document.selection.clear()):h.select(),f)this.moveToPosition(f,u.POSITION_BEFORE_START),f._4e_remove()}else this.setEndBefore(n),n._4e_remove(),h.select()};p.getSelection=r;return h.Selection=p},{requires:["./base","./walker","./range","./dom","node"]});
KISSY.add("editor/core/selectionFix",function(e,h){function p(b){function c(a,b){var c=g.body.createTextRange();try{c.moveToPoint(a,b)}catch(d){c=o}return c}function d(){var b=g.selection.createRange();l&&!b.item&&0===b.compareEndPoints("StartToEnd",b)&&l.select();u.remove(g,"mouseup",d);u.remove(g,"mousemove",e);l=a=0}function e(a){if(a.button){if(a=c(a.pageX,a.pageY))0<a.compareEndPoints("StartToStart",l)?a.setEndPoint("StartToStart",l):a.setEndPoint("EndToEnd",l),a.select()}else d()}var a,i=b.get("window")[0],
g=b.get("document")[0],l;u.on(g,"mousedown contextmenu",function(b){var f=g.documentElement;if(b.target===f&&(a&&d(),!(f.scrollHeight>f.clientHeight)&&(a=1,l=c(b.pageX,b.pageY))))u.on(g,"mouseup",d),u.on(g,"mousemove",e),i.focus(),l.select()})}function r(e){function c(a){if(g){var j=e.getSelection(),l=j&&j.getType(),k=j&&d.selection;if(a&&k&&l==y.SELECTION_NONE&&!d.queryCommandEnabled("InsertImage"))setTimeout(function(){c(b)},50);else{var h;if(!k||!k.type||!("Control"!=k.type&&(h=k.createRange())&&
(h=h.parentElement())&&(h=h.nodeName)&&h.toLowerCase()in{input:1,textarea:1}))i=k&&j.getRanges()[0],e.checkSelectionChange()}}}var d=e.get("document")[0],j=new w(d.body),a=new w(d.documentElement);if(8>h.Utils.ieEngine)a.on("click",function(a){"html"===(new w(a.target)).nodeName()&&e.getSelection().getNative().createRange().select()});var i,g,l=b;a.on("mousedown",function(){l=k});a.on("mouseup",function(){l=b});j.on("focusin",function(a){if("body"==(new w(a.target)).nodeName()&&i){try{l&&i.select()}catch(b){}i=
o}});j.on("focus",function(){g=b;c()});j.on("beforedeactivate",function(a){a.relatedTarget||(g=k,l=b)});j.on("mousedown",function(){g=k});j.on("mouseup",function(){g=b;setTimeout(function(){c(b)},0)});j.on("keydown",function(){g=k});j.on("keyup",function(){g=b;setTimeout(function(){c()},0)})}function m(b){var c=b.get("document")[0];u.on(c,"mouseup keyup selectionchange",function(){b.checkSelectionChange()})}function v(e){function c(a){var b=h.XHTML_DTD;return a._4e_isBlockBoundary()&&b.$empty[a.nodeName()]}
function d(b){return a(b)&&i(b)}var o=/\s*<(p|div|address|h\d|center)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;|(<\!--[\s\S]*?--\>))?\s*(:?<\/\1>)?(?=\s*$|<\/body>)/gi,a=h.Walker.whitespaces(b),i=h.Walker.bookmark(k,b),g=function(b){return a(b)&&8!=b.nodeType};e.on("selectionChange",function(a){var i=a.path,m=new w(e.get("document")[0].body),a=(a=a.selection)&&a.getRanges()[0],p=i.blockLimit;if(n.gecko){var r=i.block||i.blockLimit,u=r&&r.last(d);r&&r._4e_isBlockBoundary()&&(!u||!(1==u[0].nodeType&&
u._4e_isBlockBoundary()))&&"pre"!=r.nodeName()&&!r._4e_getBogus()&&r._4e_appendBogus()}if(a&&a.collapsed&&!i.block){if("body"==p.nodeName()){if((i=a.fixBlock(b,"p"))&&i[0]!=m[0].lastChild&&i.outerHtml().match(o))if((p=i.next(g,1))&&p[0].nodeType==j.NodeType.ELEMENT_NODE&&!c[p])a.moveToElementEditablePosition(p),i._4e_remove();else if((p=i.prev(g,1))&&p[0].nodeType==j.NodeType.ELEMENT_NODE&&!c[p])a.moveToElementEditablePosition(p,p.outerHtml().match(o)?k:b),i._4e_remove();a.select();e.notifySelectionChange()}i=
e.get("document")[0];a=new h.Range(i);a.moveToElementEditablePosition(m,b);"body"!==(new h.ElementPath(a.startContainer)).blockLimit.nodeName()&&(m=(new w(i.createElement("p"))).appendTo(m),n.ie||m._4e_appendBogus())}})}var b=!0,k=!1,o=null,n=e.UA,u=e.Event,j=e.DOM,w=e.Node,y=h.SELECTION;return{init:function(b){b.docReady(function(){n.ie?(p(b),r(b)):m(b)});v(b)}}},{requires:["./base","./selection","node"]});
KISSY.add("editor/core/styles",function(e,h){function p(a){return!z.attr(a,"_ke_bookmark")}function r(a,b){for(var c in a)"string"==typeof a[c]?a[c]=a[c].replace(T,function(a,c){return b[c]}):r(a[c],b)}function m(a,b){b&&(a=e.clone(a),r(a,b));var c=this.element=this.element=(a.element||"*").toLowerCase();this.type=this.type="#text"==c||S[c]?D.STYLE_BLOCK:Q[c]?D.STYLE_OBJECT:D.STYLE_INLINE;this._={definition:a}}function v(a,b){var c=b?this.removeFromRange:this.applyToRange;a.body.focus();for(var d=
new q(a),e=d.getRanges(),f=0;f<e.length;f++)c.call(this,e[f]);d.selectRanges(e)}function b(a,b,c){var d=a.element;"*"==d&&(d="span");b=new F(b.createElement(d));c&&c._4e_copyAttributes(b);c=a._.definition;a=c.attributes;c=m.getStyleText(c);if(a)for(var e in a)b.attr(e,a[e]);c&&(b[0].style.cssText=c);return b}function k(a){var c=a.createBookmark(l),d=a.createIterator();d.enforceRealBlocks=l;d.enlargeBr=l;for(var e,f=a.document;e=d.getNextParagraph();){var g=b(this,f,e),i=g,g="pre"==i.nodeName,j="pre"==
e.nodeName,k=!g&&j;g&&!j?(j=e,k=j.html(),k=o(k,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,""),k=k.replace(/[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi,"$1"),k=k.replace(/([ \t\n\r]+|&nbsp;)/g," "),k=k.replace(/<br\b[^>]*>/gi,"\n"),M.ie?(j=j[0].ownerDocument.createElement("div"),j.appendChild(i[0]),i.outerHtml("<pre>"+k+"</pre>"),i=new F(j.firstChild),i._4e_remove()):i.html(k)):k?i=u(n(e),i):e._4e_moveChildren(i);e[0].parentNode.replaceChild(i[0],e[0]);if(g&&(e=i,g=void 0,(g=e._4e_previousSourceNode(l,z.NodeType.ELEMENT_NODE))&&
"pre"==g.nodeName()))i=o(g.html(),/\n$/,"")+"\n\n"+o(e.html(),/^\n/,""),M.ie?e.outerHtml("<pre>"+i+"</pre>"):e.html(i),g._4e_remove()}a.moveToBookmark(c)}function o(a,b,c){var d="",e="",a=a.replace(/(^<span[^>]+_ke_bookmark.*?\/span>)|(<span[^>]+_ke_bookmark.*?\/span>$)/gi,function(a,b,c){b&&(d=b);c&&(e=c);return""});return d+a.replace(b,c)+e}function n(a){var b=[];o(a.outerHtml(),/(\S\s*)\n(?:\s|(<span[^>]+_ck_bookmark.*?\/span>))*\n(?!$)/gi,function(a,b,c){return b+"</pre>"+c+"<pre>"}).replace(/<pre\b.*?>([\s\S]*?)<\/pre>/gi,
function(a,c){b.push(c)});return b}function u(a,b){for(var c=b[0].ownerDocument.createDocumentFragment(),d=0;d<a.length;d++){var e=a[d],e=e.replace(/(\r\n|\r)/g,"\n"),e=o(e,/^[ \t]*\n/,""),e=o(e,/\n$/,""),e=o(e,/^[ \t]+|[ \t]+$/g,function(a,b){return 1==a.length?"&nbsp;":b?" "+Array(a.length).join("&nbsp;"):Array(a.length).join("&nbsp;")+" "}),e=e.replace(/\n/g,"<br>"),e=e.replace(/[ \t]{2,}/g,function(a){return Array(a.length).join("&nbsp;")+" "}),f=b.clone();f.html(e);c.appendChild(f[0])}return c}
function j(c){var d=c.document;if(c.collapsed)d=b(this,d,void 0),c.insertNode(d),c.moveToPosition(d,G.POSITION_BEFORE_END);else{var e=this.element,f=this._.definition,g,i=L[e];i||(g=l,i=L.span);var j=c.createBookmark();c.enlarge(G.ENLARGE_ELEMENT);c.trim();for(var k=c.createBookmark(),h=k.startNode,k=k.endNode,o=h,n;o&&o[0];){var m=s;if(z.equals(o,k))o=B,m=l;else{var t=o[0].nodeType,r=t==z.NodeType.ELEMENT_NODE?o.nodeName():B;if(r&&o.attr("_ke_bookmark")){o=o._4e_nextSourceNode(l);continue}if(!r||
i[r]&&(o._4e_position(k)|x.POSITION_PRECEDING|x.POSITION_IDENTICAL|x.POSITION_IS_CONTAINED)==x.POSITION_PRECEDING+x.POSITION_IDENTICAL+x.POSITION_IS_CONTAINED&&(!f.childRule||f.childRule(o))){var q=o.parent();if(q&&"a"==e&&q.nodeName()==e)t=b(this,d,void 0),q._4e_moveChildren(t),q[0].parentNode.replaceChild(t[0],q[0]),t._4e_mergeSiblings();else if(q&&q[0]&&((L[q.nodeName()]||L.span)[e]||g)&&(!f.parentRule||f.parentRule(q))){if(!n&&(!r||!L.$removeEmpty[r]||(o._4e_position(k)|x.POSITION_PRECEDING|x.POSITION_IDENTICAL|
x.POSITION_IS_CONTAINED)==x.POSITION_PRECEDING+x.POSITION_IDENTICAL+x.POSITION_IS_CONTAINED))n=new I(d),n.setStartBefore(o);if(t==z.NodeType.TEXT_NODE||t==z.NodeType.ELEMENT_NODE&&!o[0].childNodes.length){q=o;for(t=null;(m=!q.next(p,1))&&(t=q.parent())&&i[t.nodeName()]&&(t._4e_position(h)|x.POSITION_FOLLOWING|x.POSITION_IDENTICAL|x.POSITION_IS_CONTAINED)==x.POSITION_FOLLOWING+x.POSITION_IDENTICAL+x.POSITION_IS_CONTAINED&&(!f.childRule||f.childRule(t));)q=t;n.setEndAfter(q)}}else m=l}else m=l;o=o._4e_nextSourceNode()}if(m&&
n&&!n.collapsed){for(var m=b(this,d,void 0),q=n.getCommonAncestor(),t={},r={},u,v=null,w;m&&q&&m[0]&&q[0];){if(q.nodeName()==e){for(u in f.attributes)if(!r[u]&&(w=q.attr(v)))m.attr(u)==w?m.removeAttr(u):r[u]=1;for(v in f.styles)if(!t[v]&&(w=q.style(v)))m.style(v)==w?m.style(v,""):t[v]=1;if(!m._4e_hasAttributes()){m=B;break}}q=q.parent()}m?(m[0].appendChild(n.extractContents()),a(this,m),n.insertNode(m),m._4e_mergeSiblings(),M.ie||m[0].normalize()):(m=new F(d.createElement("span")),m[0].appendChild(n.extractContents()),
n.insertNode(m),a(this,m),m._4e_remove(!0));n=B}}h._4e_remove();k._4e_remove();c.moveToBookmark(j);c.shrink(G.SHRINK_TEXT)}}function w(a){a.enlarge(G.ENLARGE_ELEMENT);var b=a.createBookmark(),e=b.startNode;if(a.collapsed){for(var f=new O(e.parent()),g,k=0,j;k<f.elements.length&&(j=f.elements[k])&&!(j==f.block||j==f.blockLimit);k++)if(this.checkElementRemovable(j)){var h=a.checkBoundaryOfElement(j,G.END),l=!h&&a.checkBoundaryOfElement(j,G.START);l||h?(g=j,g.match=l?"start":"end"):(j._4e_mergeSiblings(),
j.nodeName()!=this.element?(h=c(this),i(j,h[j.nodeName()]||h["*"])):d(this,j))}if(g){j=e;for(k=0;;k++){h=f.elements[k];if(h.equals(g))break;else if(h.match)continue;else h=h.clone();h[0].appendChild(j[0]);j=h}j["start"==g.match?"insertBefore":"insertAfter"](g);f=g.html();!f||"\u200b"==f?g.remove():M.webkit&&C(a.document.createTextNode("\u200b")).insertBefore(j)}}else{var o=b.endNode,n=this;g=function(){for(var a=new O(e.parent()),b=new O(o.parent()),c=B,d=B,f=0;f<a.elements.length;f++){var g=a.elements[f];
if(g==a.block||g==a.blockLimit)break;n.checkElementRemovable(g)&&(c=g)}for(f=0;f<b.elements.length;f++){g=b.elements[f];if(g==b.block||g==b.blockLimit)break;n.checkElementRemovable(g)&&(d=g)}d&&o._4e_breakParent(d);c&&e._4e_breakParent(c)};g();for(f=new F(e[0].nextSibling);f[0]!==o[0];){k=f._4e_nextSourceNode();if(f[0]&&f[0].nodeType==z.NodeType.ELEMENT_NODE&&this.checkElementRemovable(f)&&(f.nodeName()==this.element?d(this,f):(j=c(this),i(f,j[f.nodeName()]||j["*"])),k[0].nodeType==z.NodeType.ELEMENT_NODE&&
k.contains(e)))g(),k=new F(e[0].nextSibling);f=k}}a.moveToBookmark(b)}function y(a){var b={};(""+a).replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(a,c,d){b[c]=d});return b}function f(a,b){var c="";b!==s?(c=document.createElement("span"),c.style.cssText=a,c=c.style.cssText||""):c=a;return c.replace(/\s*([;:])\s*/,"$1").replace(/([^\s;])$/,"$1;").replace(/,\s+/g,",").toLowerCase()}function c(a){if(a._.overrides)return a._.overrides;var b=a._.overrides={},c=a._.definition.overrides;
if(c){e.isArray(c)||(c=[c]);for(var d=0;d<c.length;d++){var f=c[d],g,i,j;"string"==typeof f?g=f.toLowerCase():(g=f.element?f.element.toLowerCase():a.element,i=f.attributes,j=f.styles);f=b[g]||(b[g]={});if(i){g=f.attributes=f.attributes||[];for(var k in i)g.push([k.toLowerCase(),i[k]])}if(j){var f=f.styles=f.styles||[],h;for(h in j)f.push([h.toLowerCase(),j[h]])}}}return b}function d(a,b){var d=a._.definition,f=c(a),i=e.merge(d.attributes,(f[b.nodeName()]||f["*"]||{}).attributes),d=e.merge(d.styles,
(f[b.nodeName()]||f["*"]||{}).styles),f=e.isEmptyObject(i)&&e.isEmptyObject(d),j;for(j in i)("class"==j||a._.definition.fullMatch)&&b.attr(j)!=t(j,i[j])||(f=f||!!b.hasAttr(j),b.removeAttr(j));for(var k in d)a._.definition.fullMatch&&b.style(k)!=t(k,d[k],l)||(f=f||!!b.style(k),b.style(k,""));g(b)}function t(a,b,c){var d=new F("<span>");d[c?"style":"attr"](a,b);return d[c?"style":"attr"](a)}function a(a,b){for(var e=c(a),f=b.all(a.element),g=f.length;0<=--g;)d(a,new F(f[g]));for(var j in e)if(j!=a.element){f=
b.all(j);for(g=f.length-1;0<=g;g--){var k=new F(f[g]);i(k,e[j])}}}function i(a,b){var c,d=b&&b.attributes;if(d)for(c=0;c<d.length;c++){var e=d[c][0],f;if(f=a.attr(e)){var i=d[c][1];(i===B||i.test&&i.test(f)||"string"==typeof i&&f==i)&&a[0].removeAttribute(e)}}if(d=b&&b.styles)for(c=0;c<d.length;c++)if(e=d[c][0],i=a.css(e)){var j=d[c][1];(j===B||j.test&&j.test(f)||"string"==typeof j&&i==j)&&a.css(e,"")}g(a)}function g(a){if(!a._4e_hasAttributes()){var b=a[0].firstChild,c=a[0].lastChild;a._4e_remove(l);
b&&(b.nodeType==z.NodeType.ELEMENT_NODE&&z._4e_mergeSiblings(b),c&&b!=c&&c.nodeType==z.NodeType.ELEMENT_NODE&&z._4e_mergeSiblings(c))}}var l=!0,s=!1,B=null,C=e.all,z=e.DOM,D={STYLE_BLOCK:1,STYLE_INLINE:2,STYLE_OBJECT:3},G=h.RANGE,q=h.Selection,x=h.POSITION,I=h.Range,F=e.Node,M=e.UA,O=h.ElementPath,S={address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1},L=h.XHTML_DTD,Q={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},R=/\s*(?:;\s*|$)/g,T=/#\((.+?)\)/g;h.STYLE=
D;m.prototype={constructor:m,apply:function(a){v.call(this,a,s)},remove:function(a){v.call(this,a,l)},applyToRange:function(a){return(this.applyToRange=this.type==D.STYLE_INLINE?j:this.type==D.STYLE_BLOCK?k:B).call(this,a)},removeFromRange:function(a){return(this.removeFromRange=this.type==D.STYLE_INLINE?w:B).call(this,a)},checkElementRemovable:function(a,b){if(!a)return s;var d=this._.definition,e;if(a.nodeName()==this.element){if(!b&&!a._4e_hasAttributes())return l;var g=d._AC;if(g)d=g;else{var g=
{},i=0,j=d.attributes;if(j)for(var k in j)i++,g[k]=j[k];if(j=m.getStyleText(d))g.style||i++,g.style=j;g._length=i;d=d._AC=g}if(d._length){for(var h in d)if("_length"!=h){i=a.attr(h)||"";if("style"==h)a:{g=d[h];i=f(i,s);"string"==typeof g&&(g=y(g));"string"==typeof i&&(i=y(i));j=void 0;for(j in g)if(!(j in i&&(i[j]==g[j]||"inherit"==g[j]||"inherit"==i[j]))){g=s;break a}g=l}else g=d[h]==i;if(g){if(!b)return l}else if(b)return s}if(b)return l}else return l}h=c(this);if(h=h[a.nodeName()]||h["*"]){if(!(d=
h.attributes)&&!(e=h.styles))return l;if(d)for(g=0;g<d.length;g++)if(h=d[g][0],h=a.attr(h))if(i=d[g][1],i===B||"string"==typeof i&&h==i||i.test&&i.test(h))return l;if(e)for(g=0;g<e.length;g++)if(h=a.css(e[g][0]))if(d=e[g][1],d===B||"string"==typeof d&&h==d||d.test&&d.test(h))return l}return s},checkActive:function(a){switch(this.type){case D.STYLE_BLOCK:return this.checkElementRemovable(a.block||a.blockLimit,l);case D.STYLE_OBJECT:case D.STYLE_INLINE:for(var b=a.elements,c=0,d;c<b.length;c++)if(d=
b[c],!(this.type==D.STYLE_INLINE&&(z.equals(d,a.block)||z.equals(d,a.blockLimit))))if((this.type!=D.STYLE_OBJECT||d.nodeName()in Q)&&this.checkElementRemovable(d,l))return l}return s}};m.getStyleText=function(a){var b=a._ST;if(b)return b;var b=a.styles,c=a.attributes&&a.attributes.style||"",d="";c.length&&(c=c.replace(R,";"));for(var e in b){var g=b[e],i=(e+":"+g).replace(R,";");"inherit"==g?d+=i:c+=i}c.length&&(c=f(c));return a._ST=c+d};return h.Style=m},{requires:"./base,./range,./selection,./domIterator,./elementPath,node".split(",")});
KISSY.add("editor/core/utils",function(e,h){var p=e.Node,r=e.DOM,m=e.UA,v={debugUrl:function(b){var k=e.Config;k.debug||(b=b.replace(/\.(js|css)/i,"-min.$1"));-1==b.indexOf("?t")&&(b=-1!=b.indexOf("?")?b+"&":b+"?",b+="t="+encodeURIComponent(k.tag));return k.base+"editor/"+b},lazyRun:function(b,e,h){var n=b[e],m=b[h];b[e]=function(){n.apply(this,arguments);b[e]=b[h];return m.apply(this,arguments)}},getXY:function(b,e){var h=b.left,n=b.top,m=e.get("window")[0],h=h-r.scrollLeft(m),n=n-r.scrollTop(m),
m=e.get("iframe").offset(),h=h+m.left,n=n+m.top;return{left:h,top:n}},tryThese:function(b){for(var e,h=0,n=arguments.length;h<n;h++){var m=arguments[h];try{e=m();break}catch(j){}}return e},arrayCompare:function(b,e){if(!b&&!e)return!0;if(!b||!e||b.length!=e.length)return!1;for(var h=0;h<b.length;h++)if(b[h]!==e[h])return!1;return!0},clearAllMarkers:function(b){for(var e in b)b[e]._4e_clearMarkers(b,!0,void 0)},ltrim:function(b){return b.replace(/^\s+/,"")},rtrim:function(b){return b.replace(/\s+$/,
"")},isNumber:function(b){return/^\d+(.\d+)?$/.test(e.trim(b))},verifyInputs:function(b){for(var h=0;h<b.length;h++){var m=new p(b[h]),n=e.trim(v.valInput(m)),r=m.attr("data-verify"),m=m.attr("data-warning");if(r&&!RegExp(r).test(n))return alert(m),!1}return!0},sourceDisable:function(b,e){b.on("sourceMode",e.disable,e);b.on("wysiwygMode",e.enable,e)},resetInput:function(b){var e=b.attr("placeholder");e&&m.ie?(b.addClass("ks-editor-input-tip"),b.val(e)):m.ie||b.val("")},valInput:function(b,e){if(void 0===
e)return b.hasClass("ks-editor-input-tip")?"":b.val();b.removeClass("ks-editor-input-tip");b.val(e)},placeholder:function(b,h){b.attr("placeholder",h);m.ie&&(b.on("blur",function(){e.trim(b.val())||(b.addClass("ks-editor-input-tip"),b.val(h))}),b.on("focus",function(){b.removeClass("ks-editor-input-tip");e.trim(b.val())==h&&b.val("")}))},htmlEncode:function(b){return!b?b:(""+b).replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},normParams:function(b){var b=e.clone(b),
h;for(h in b){var m=b[h];"function"===typeof m&&(b[h]=m())}return b},map:function(b,e){for(var h=0;h<b.length;h++)b[h]=e(b[h]);return b},ieEngine:document.documentMode||m.ie,preventFocus:function(b){m.ie?b.unselectable():b.attr("onmousedown","return false;")},injectDom:function(b){e.mix(r,b);for(var h in b)(function(h){p.prototype[h]=function(){var k=[].slice.call(arguments,0);k.unshift(this[0]);return(k=b[h].apply(null,k))&&(k.nodeType||e.isWindow(k))?new p(k):e.isArray(k)&&(k.__IS_NODELIST||k[0]&&
k[0].nodeType)?new p(k):k}})(h)},addRes:function(){var b=this.__res=this.__res||[];b.push.apply(b,e.makeArray(arguments))},destroyRes:function(){for(var b=this.__res||[],e=0;e<b.length;e++){var h=b[e];"function"===typeof h?h():h.destroy?h.destroy():h.remove&&h.remove()}this.__res=[]},getQueryCmd:function(b){return"query"+("-"+b).replace(/-(\w)/g,function(b,e){return e.toUpperCase()})+"Value"}};return h.Utils=v},{requires:["./base","node"]});
KISSY.add("editor/core/walker",function(e,h){function p(c,e){if(this._.end)return k;var a,f=this.range,g,h=this.guard,m=this.type,o=c?"_4e_previousSourceNode":"_4e_nextSourceNode";if(!this._.start&&(this._.start=1,f.trim(),f.collapsed))return this.end(),k;if(!c&&!this._.guardLTR){var p=f.endContainer[0],r=p.childNodes[f.endOffset];this._.guardLTR=function(a,b){return b&&(p==a||"body"==n.nodeName(a))?!1:a!=r}}if(c&&!this._.guardRTL){var u=f.startContainer[0],w=0<f.startOffset&&u.childNodes[f.startOffset-
1]||null;this._.guardRTL=function(a,b){return b&&(u==a||"body"==n.nodeName(a))?!1:a!=w}}var q=c?this._.guardRTL:this._.guardLTR;g=h?function(a,c){return q(a,c)===b?b:h(a,c)}:q;this.current?a=this.current[o](b,m,g):c?(a=f.endContainer,0<f.endOffset?(a=new j(a[0].childNodes[f.endOffset-1]),g(a[0])===b&&(a=k)):a=g(a,v)===b?k:a._4e_previousSourceNode(v,m,g,void 0)):(a=f.startContainer,a=new j(a[0].childNodes[f.startOffset]),a.length?g(a[0])===b&&(a=k):a=g(f.startContainer,v)===b?k:f.startContainer._4e_nextSourceNode(v,
m,g,void 0));for(;a&&!this._.end;){this.current=a;if(!this.evaluator||this.evaluator(a[0])!==b){if(!e)return a}else if(e&&this.evaluator)return b;a=a[o](b,m,g)}this.end();return this.current=k}function r(b){for(var c,a=k;c=p.call(this,b);)a=c;return a}function m(b){this.range=b;this.guard=this.evaluator=k;this._={}}var v=!0,b=!1,k=null,o=e.UA,n=e.DOM,u=h.XHTML_DTD,j=e.Node;e.augment(m,{end:function(){this._.end=1},next:function(){return p.call(this)},previous:function(){return p.call(this,v)},checkForward:function(){return p.call(this,
b,v)!==b},checkBackward:function(){return p.call(this,v,v)!==b},lastForward:function(){return r.call(this)},lastBackward:function(){return r.call(this,v)},reset:function(){delete this.current;this._={}},_iterator:p});e.mix(m,{blockBoundary:function(b){return function(c){return!(c.nodeType==n.NodeType.ELEMENT_NODE&&n._4e_isBlockBoundary(c,b))}},bookmark:function(b,c){function a(a){return"span"==n.nodeName(a)&&n.attr(a,"_ke_bookmark")}return function(e){var f,h;f=e.nodeType==n.NodeType.TEXT_NODE&&(h=
e.parentNode)&&a(h);f=b?f:f||a(e);return!!(c^f)}},whitespaces:function(b){return function(c){c=c.nodeType==n.NodeType.TEXT_NODE&&!e.trim(c.nodeValue);return!!(b^c)}},invisible:function(b){var c=m.whitespaces();return function(a){a=c(a)||a.nodeType==n.NodeType.ELEMENT_NODE&&!a.offsetHeight;return!!(b^a)}}});var w=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,y=m.whitespaces(),f=m.bookmark(),c=function(b){var c=n.nodeName(b);return f(b)||y(b)||1==b.nodeType&&c in u.$inline&&!(c in u.$empty)};h.Utils.injectDom({_4e_getBogus:function(b){b=
new j(b);do b=b._4e_previousSourceNode();while(b&&c(b[0]));return b&&(!o.ie?"br"==b.nodeName():3==b[0].nodeType&&w.test(b.text()))?b[0]:!1}});return h.Walker=m},{requires:["./base","./utils","./dom","node"]});KISSY.add("editor/core/zIndexManager",function(e,h){var p=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(e){return(h.Config.baseZIndex||1E4)+e};return p},{requires:["./base"]});
