(function(){CKEDITOR.plugins.add('enterkey',{requires:['keystrokes','indent'],init:function(h){h.addCommand('enter',{modes:{wysiwyg:1},editorFocus:false,exec:function(j){f(j);}});h.addCommand('shiftEnter',{modes:{wysiwyg:1},editorFocus:false,exec:function(j){e(j);}});var i=h.keystrokeHandler.keystrokes;i[13]='enter';i[CKEDITOR.SHIFT+13]='shiftEnter';}});CKEDITOR.plugins.enterkey={enterBlock:function(h,i,j,k){j=j||g(h);if(!j)return;var l=j.document,m=j.checkStartOfBlock(),n=j.checkEndOfBlock(),o=new CKEDITOR.dom.elementPath(j.startContainer),p=o.block;if(m&&n){if(p&&(p.is('li')||p.getParent().is('li'))){h.execCommand('outdent');return;}}else if(!n&&p&&p.is('pre'))b(h,i,j,k);var q=i==CKEDITOR.ENTER_DIV?'div':'p',r=j.splitBlock(q);if(!r)return;var s=r.previousBlock,t=r.nextBlock,u=r.wasStartOfBlock,v=r.wasEndOfBlock,w;if(t){w=t.getParent();if(w.is('li')){t.breakParent(w);t.move(t.getNext(),1);}}else if(s&&(w=s.getParent())&&w.is('li')){s.breakParent(w);w=s.getNext();j.moveToElementEditStart(w);s.move(s.getPrevious());}if(!u&&!v){if(t.is('li')&&(w=t.getFirst(CKEDITOR.dom.walker.invisible(true)))&&w.is&&w.is('ul','ol'))(CKEDITOR.env.ie?l.createText('\xa0'):l.createElement('br')).insertBefore(w);if(t)j.moveToElementEditStart(t);}else{var x,y;if(s){if(s.is('li')||!(d.test(s.getName())||s.is('pre'))){x=s.clone();x.is('li')&&x.removeAttribute('value');}}else if(t)x=t.clone();if(!x){if(w&&w.is('li'))x=w;else{x=l.createElement(q);if(s&&(y=s.getDirection()))x.setAttribute('dir',y);}}else if(k&&!x.is('li'))x.renameNode(q);var z=r.elementPath;if(z)for(var A=0,B=z.elements.length;A<B;A++){var C=z.elements[A];if(C.equals(z.block)||C.equals(z.blockLimit))break;if(CKEDITOR.dtd.$removeEmpty[C.getName()]){C=C.clone();x.moveChildren(C);x.append(C);}}if(!CKEDITOR.env.ie)x.appendBogus();if(!x.getParent())j.insertNode(x);if(CKEDITOR.env.ie&&u&&(!v||!s.getChildCount())){j.moveToElementEditStart(v?s:x);j.select();}j.moveToElementEditStart(u&&!v?t:x);}if(!CKEDITOR.env.ie)if(t){var D=l.createElement('span');D.setHtml('&nbsp;');j.insertNode(D);D.scrollIntoView();j.deleteContents();}else x.scrollIntoView();j.select();},enterBr:function(h,i,j,k){j=j||g(h);if(!j)return;var l=j.document,m=i==CKEDITOR.ENTER_DIV?'div':'p',n=j.checkEndOfBlock(),o=new CKEDITOR.dom.elementPath(h.getSelection().getStartElement()),p=o.block,q=p&&o.block.getName(),r=false;if(!k&&q=='li'){c(h,i,j,k);return;}if(!k&&n&&d.test(q)){var s,t;if(t=p.getDirection()){s=l.createElement('div');s.setAttribute('dir',t);s.insertAfter(p);
j.setStart(s,0);}else{l.createElement('br').insertAfter(p);if(CKEDITOR.env.gecko)l.createText('').insertAfter(p);j.setStartAt(p.getNext(),CKEDITOR.env.ie?CKEDITOR.POSITION_BEFORE_START:CKEDITOR.POSITION_AFTER_START);}}else{var u;r=q=='pre';if(r&&!CKEDITOR.env.gecko)u=l.createText(CKEDITOR.env.ie?'\r':'\n');else u=l.createElement('br');j.deleteContents();j.insertNode(u);if(CKEDITOR.env.ie)j.setStartAt(u,CKEDITOR.POSITION_AFTER_END);else{l.createText('\ufeff').insertAfter(u);if(n)u.getParent().appendBogus();u.getNext().$.nodeValue='';j.setStartAt(u.getNext(),CKEDITOR.POSITION_AFTER_START);var v=null;if(!CKEDITOR.env.gecko){v=l.createElement('span');v.setHtml('&nbsp;');}else v=l.createElement('br');v.insertBefore(u.getNext());v.scrollIntoView();v.remove();}}j.collapse(true);j.select(r);}};var a=CKEDITOR.plugins.enterkey,b=a.enterBr,c=a.enterBlock,d=/^h[1-6]$/;function e(h){if(h.mode!='wysiwyg')return false;return f(h,h.config.shiftEnterMode,1);};function f(h,i,j){j=h.config.forceEnterMode||j;if(h.mode!='wysiwyg')return false;if(!i)i=h.config.enterMode;setTimeout(function(){h.fire('saveSnapshot');if(i==CKEDITOR.ENTER_BR)b(h,i,null,j);else c(h,i,null,j);},0);return true;};function g(h){var i=h.getSelection().getRanges(true);for(var j=i.length-1;j>0;j--)i[j].deleteContents();return i[0];};})();
