Archived
(Experimental) Replace htmlarea with XINHA. Thanks to abdussamad!
This commit is contained in:
@@ -0,0 +1,461 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Gecko/Gecko.js */
|
||||
Gecko._pluginInfo={name:"Gecko",origin:"Xinha Core",version:"$LastChangedRevision:998 $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),developer:"The Xinha Core Developer Team",developer_url:"$HeadURL:http://svn.xinha.webfactional.com/trunk/modules/Gecko/Gecko.js $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),sponsor:"",sponsor_url:"",license:"htmlArea"};
|
||||
function Gecko(_1){
|
||||
this.editor=_1;
|
||||
_1.Gecko=this;
|
||||
}
|
||||
Gecko.prototype.onKeyPress=function(ev){
|
||||
var _3=this.editor;
|
||||
var s=_3.getSelection();
|
||||
if(_3.isShortCut(ev)){
|
||||
switch(_3.getKey(ev).toLowerCase()){
|
||||
case "z":
|
||||
if(_3._unLink&&_3._unlinkOnUndo){
|
||||
Xinha._stopEvent(ev);
|
||||
_3._unLink();
|
||||
_3.updateToolbar();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "a":
|
||||
sel=_3.getSelection();
|
||||
sel.removeAllRanges();
|
||||
range=_3.createRange();
|
||||
range.selectNodeContents(_3._doc.body);
|
||||
sel.addRange(range);
|
||||
Xinha._stopEvent(ev);
|
||||
return true;
|
||||
break;
|
||||
case "v":
|
||||
if(!_3.config.htmlareaPaste){
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(_3.getKey(ev)){
|
||||
case " ":
|
||||
var _5=function(_6,_7){
|
||||
var _8=_6.nextSibling;
|
||||
if(typeof _7=="string"){
|
||||
_7=_3._doc.createElement(_7);
|
||||
}
|
||||
var a=_6.parentNode.insertBefore(_7,_8);
|
||||
Xinha.removeFromParent(_6);
|
||||
a.appendChild(_6);
|
||||
_8.data=" "+_8.data;
|
||||
s.collapse(_8,1);
|
||||
_3._unLink=function(){
|
||||
var t=a.firstChild;
|
||||
a.removeChild(t);
|
||||
a.parentNode.insertBefore(t,a);
|
||||
Xinha.removeFromParent(a);
|
||||
_3._unLink=null;
|
||||
_3._unlinkOnUndo=false;
|
||||
};
|
||||
_3._unlinkOnUndo=true;
|
||||
return a;
|
||||
};
|
||||
if(_3.config.convertUrlsToLinks&&s&&s.isCollapsed&&s.anchorNode.nodeType==3&&s.anchorNode.data.length>3&&s.anchorNode.data.indexOf(".")>=0){
|
||||
var _b=s.anchorNode.data.substring(0,s.anchorOffset).search(/\S{4,}$/);
|
||||
if(_b==-1){
|
||||
break;
|
||||
}
|
||||
if(_3._getFirstAncestor(s,"a")){
|
||||
break;
|
||||
}
|
||||
var _c=s.anchorNode.data.substring(0,s.anchorOffset).replace(/^.*?(\S*)$/,"$1");
|
||||
var _d=_c.match(Xinha.RE_email);
|
||||
if(_d){
|
||||
var _e=s.anchorNode;
|
||||
var _f=_e.splitText(s.anchorOffset);
|
||||
var _10=_e.splitText(_b);
|
||||
_5(_10,"a").href="mailto:"+_d[0];
|
||||
break;
|
||||
}
|
||||
RE_date=/([0-9]+\.)+/;
|
||||
RE_ip=/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/;
|
||||
var _11=_c.match(Xinha.RE_url);
|
||||
if(_11){
|
||||
if(RE_date.test(_c)){
|
||||
break;
|
||||
}
|
||||
var _12=s.anchorNode;
|
||||
var _13=_12.splitText(s.anchorOffset);
|
||||
var _14=_12.splitText(_b);
|
||||
_5(_14,"a").href=(_11[1]?_11[1]:"http://")+_11[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch(ev.keyCode){
|
||||
case 27:
|
||||
if(_3._unLink){
|
||||
_3._unLink();
|
||||
Xinha._stopEvent(ev);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 8:
|
||||
case 46:
|
||||
if(!ev.shiftKey&&this.handleBackspace()){
|
||||
Xinha._stopEvent(ev);
|
||||
}
|
||||
default:
|
||||
_3._unlinkOnUndo=false;
|
||||
if(s.anchorNode&&s.anchorNode.nodeType==3){
|
||||
var a=_3._getFirstAncestor(s,"a");
|
||||
if(!a){
|
||||
break;
|
||||
}
|
||||
if(!a._updateAnchTimeout){
|
||||
if(s.anchorNode.data.match(Xinha.RE_email)&&a.href.match("mailto:"+s.anchorNode.data.trim())){
|
||||
var _16=s.anchorNode;
|
||||
var _17=function(){
|
||||
a.href="mailto:"+_16.data.trim();
|
||||
a._updateAnchTimeout=setTimeout(_17,250);
|
||||
};
|
||||
a._updateAnchTimeout=setTimeout(_17,1000);
|
||||
break;
|
||||
}
|
||||
var m=s.anchorNode.data.match(Xinha.RE_url);
|
||||
if(m&&a.href.match(new RegExp("http(s)?://"+Xinha.escapeStringForRegExp(s.anchorNode.data.trim())))){
|
||||
var _19=s.anchorNode;
|
||||
var _1a=function(){
|
||||
m=_19.data.match(Xinha.RE_url);
|
||||
if(m){
|
||||
a.href=(m[1]?m[1]:"http://")+m[2];
|
||||
}
|
||||
a._updateAnchTimeout=setTimeout(_1a,250);
|
||||
};
|
||||
a._updateAnchTimeout=setTimeout(_1a,1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Gecko.prototype.handleBackspace=function(){
|
||||
var _1b=this.editor;
|
||||
setTimeout(function(){
|
||||
var sel=_1b.getSelection();
|
||||
var _1d=_1b.createRange(sel);
|
||||
var SC=_1d.startContainer;
|
||||
var SO=_1d.startOffset;
|
||||
var EC=_1d.endContainer;
|
||||
var EO=_1d.endOffset;
|
||||
var _22=SC.nextSibling;
|
||||
if(SC.nodeType==3){
|
||||
SC=SC.parentNode;
|
||||
}
|
||||
if(!(/\S/.test(SC.tagName))){
|
||||
var p=document.createElement("p");
|
||||
while(SC.firstChild){
|
||||
p.appendChild(SC.firstChild);
|
||||
}
|
||||
SC.parentNode.insertBefore(p,SC);
|
||||
Xinha.removeFromParent(SC);
|
||||
var r=_1d.cloneRange();
|
||||
r.setStartBefore(_22);
|
||||
r.setEndAfter(_22);
|
||||
r.extractContents();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(r);
|
||||
}
|
||||
},10);
|
||||
};
|
||||
Gecko.prototype.inwardHtml=function(_25){
|
||||
_25=_25.replace(/<(\/?)strong(\s|>|\/)/ig,"<$1b$2");
|
||||
_25=_25.replace(/<(\/?)em(\s|>|\/)/ig,"<$1i$2");
|
||||
_25=_25.replace(/<(\/?)del(\s|>|\/)/ig,"<$1strike$2");
|
||||
return _25;
|
||||
};
|
||||
Gecko.prototype.outwardHtml=function(_26){
|
||||
_26=_26.replace(/<script[\s]*src[\s]*=[\s]*['"]chrome:\/\/.*?["']>[\s]*<\/script>/ig,"");
|
||||
return _26;
|
||||
};
|
||||
Gecko.prototype.onExecCommand=function(_27,UI,_29){
|
||||
try{
|
||||
this.editor._doc.execCommand("useCSS",false,true);
|
||||
this.editor._doc.execCommand("styleWithCSS",false,false);
|
||||
}
|
||||
catch(ex){
|
||||
}
|
||||
switch(_27){
|
||||
case "paste":
|
||||
alert(Xinha._lc("The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly."));
|
||||
return true;
|
||||
break;
|
||||
case "removeformat":
|
||||
var _2a=this.editor;
|
||||
var sel=_2a.getSelection();
|
||||
var _2c=_2a.saveSelection(sel);
|
||||
var _2d=_2a.createRange(sel);
|
||||
var els=_2a._doc.body.getElementsByTagName("*");
|
||||
var _2f=(_2d.startContainer.nodeType==1)?_2d.startContainer:_2d.startContainer.parentNode;
|
||||
var i,el;
|
||||
if(sel.isCollapsed){
|
||||
_2d.selectNodeContents(_2a._doc.body);
|
||||
}
|
||||
for(i=0;i<els.length;i++){
|
||||
el=els[i];
|
||||
if(_2d.isPointInRange(el,0)||(els[i]==_2f&&_2d.startOffset==0)){
|
||||
el.removeAttribute("style");
|
||||
}
|
||||
}
|
||||
this.editor._doc.execCommand(_27,UI,_29);
|
||||
_2a.restoreSelection(_2c);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Gecko.prototype.onMouseDown=function(ev){
|
||||
if(ev.target.tagName.toLowerCase()=="hr"){
|
||||
var sel=this.editor.getSelection();
|
||||
var _33=this.editor.createRange(sel);
|
||||
_33.selectNode(ev.target);
|
||||
}
|
||||
};
|
||||
Xinha.prototype.insertNodeAtSelection=function(_34){
|
||||
if(_34.ownerDocument!=this._doc){
|
||||
try{
|
||||
_34=this._doc.adoptNode(_34);
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
}
|
||||
var sel=this.getSelection();
|
||||
var _36=this.createRange(sel);
|
||||
sel.removeAllRanges();
|
||||
_36.deleteContents();
|
||||
var _37=_36.startContainer;
|
||||
var pos=_36.startOffset;
|
||||
var _39=_34;
|
||||
switch(_37.nodeType){
|
||||
case 3:
|
||||
if(_34.nodeType==3){
|
||||
_37.insertData(pos,_34.data);
|
||||
_36=this.createRange();
|
||||
_36.setEnd(_37,pos+_34.length);
|
||||
_36.setStart(_37,pos+_34.length);
|
||||
sel.addRange(_36);
|
||||
}else{
|
||||
_37=_37.splitText(pos);
|
||||
if(_34.nodeType==11){
|
||||
_39=_39.firstChild;
|
||||
}
|
||||
_37.parentNode.insertBefore(_34,_37);
|
||||
this.selectNodeContents(_39);
|
||||
this.updateToolbar();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(_34.nodeType==11){
|
||||
_39=_39.firstChild;
|
||||
}
|
||||
_37.insertBefore(_34,_37.childNodes[pos]);
|
||||
this.selectNodeContents(_39);
|
||||
this.updateToolbar();
|
||||
break;
|
||||
}
|
||||
};
|
||||
Xinha.prototype.getParentElement=function(sel){
|
||||
if(typeof sel=="undefined"){
|
||||
sel=this.getSelection();
|
||||
}
|
||||
var _3b=this.createRange(sel);
|
||||
try{
|
||||
var p=_3b.commonAncestorContainer;
|
||||
if(!_3b.collapsed&&_3b.startContainer==_3b.endContainer&&_3b.startOffset-_3b.endOffset<=1&&_3b.startContainer.hasChildNodes()){
|
||||
p=_3b.startContainer.childNodes[_3b.startOffset];
|
||||
}
|
||||
while(p.nodeType==3){
|
||||
p=p.parentNode;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
catch(ex){
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Xinha.prototype.activeElement=function(sel){
|
||||
if((sel===null)||this.selectionEmpty(sel)){
|
||||
return null;
|
||||
}
|
||||
if(!sel.isCollapsed){
|
||||
if(sel.anchorNode.childNodes.length>sel.anchorOffset&&sel.anchorNode.childNodes[sel.anchorOffset].nodeType==1){
|
||||
return sel.anchorNode.childNodes[sel.anchorOffset];
|
||||
}else{
|
||||
if(sel.anchorNode.nodeType==1){
|
||||
return sel.anchorNode;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Xinha.prototype.selectionEmpty=function(sel){
|
||||
if(!sel){
|
||||
return true;
|
||||
}
|
||||
if(typeof sel.isCollapsed!="undefined"){
|
||||
return sel.isCollapsed;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Xinha.prototype.saveSelection=function(){
|
||||
return this.createRange(this.getSelection()).cloneRange();
|
||||
};
|
||||
Xinha.prototype.restoreSelection=function(_3f){
|
||||
var sel=this.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(_3f);
|
||||
};
|
||||
Xinha.prototype.selectNodeContents=function(_41,pos){
|
||||
this.focusEditor();
|
||||
this.forceRedraw();
|
||||
var _43;
|
||||
var _44=typeof pos=="undefined"?true:false;
|
||||
var sel=this.getSelection();
|
||||
_43=this._doc.createRange();
|
||||
if(!_41){
|
||||
sel.removeAllRanges();
|
||||
return;
|
||||
}
|
||||
if(_44&&_41.tagName&&_41.tagName.toLowerCase().match(/table|img|input|textarea|select/)){
|
||||
_43.selectNode(_41);
|
||||
}else{
|
||||
_43.selectNodeContents(_41);
|
||||
}
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(_43);
|
||||
};
|
||||
Xinha.prototype.insertHTML=function(_46){
|
||||
var sel=this.getSelection();
|
||||
var _48=this.createRange(sel);
|
||||
this.focusEditor();
|
||||
var _49=this._doc.createDocumentFragment();
|
||||
var div=this._doc.createElement("div");
|
||||
div.innerHTML=_46;
|
||||
while(div.firstChild){
|
||||
_49.appendChild(div.firstChild);
|
||||
}
|
||||
var _4b=this.insertNodeAtSelection(_49);
|
||||
};
|
||||
Xinha.prototype.getSelectedHTML=function(){
|
||||
var sel=this.getSelection();
|
||||
if(sel.isCollapsed){
|
||||
return "";
|
||||
}
|
||||
var _4d=this.createRange(sel);
|
||||
return Xinha.getHTML(_4d.cloneContents(),false,this);
|
||||
};
|
||||
Xinha.prototype.getSelection=function(){
|
||||
return this._iframe.contentWindow.getSelection();
|
||||
};
|
||||
Xinha.prototype.createRange=function(sel){
|
||||
this.activateEditor();
|
||||
if(typeof sel!="undefined"){
|
||||
try{
|
||||
return sel.getRangeAt(0);
|
||||
}
|
||||
catch(ex){
|
||||
return this._doc.createRange();
|
||||
}
|
||||
}else{
|
||||
return this._doc.createRange();
|
||||
}
|
||||
};
|
||||
Xinha.prototype.isKeyEvent=function(_4f){
|
||||
return _4f.type=="keypress";
|
||||
};
|
||||
Xinha.prototype.getKey=function(_50){
|
||||
return String.fromCharCode(_50.charCode);
|
||||
};
|
||||
Xinha.getOuterHTML=function(_51){
|
||||
return (new XMLSerializer()).serializeToString(_51);
|
||||
};
|
||||
Xinha.prototype.cc=String.fromCharCode(8286);
|
||||
Xinha.prototype.setCC=function(_52){
|
||||
var cc=this.cc;
|
||||
try{
|
||||
if(_52=="textarea"){
|
||||
var ta=this._textArea;
|
||||
var _55=ta.selectionStart;
|
||||
var _56=ta.value.substring(0,_55);
|
||||
var _57=ta.value.substring(_55,ta.value.length);
|
||||
if(_57.match(/^[^<]*>/)){
|
||||
var _58=_57.indexOf(">")+1;
|
||||
ta.value=_56+_57.substring(0,_58)+cc+_57.substring(_58,_57.length);
|
||||
}else{
|
||||
ta.value=_56+cc+_57;
|
||||
}
|
||||
ta.value=ta.value.replace(new RegExp("(&[^"+cc+"]*?)("+cc+")([^"+cc+"]*?;)"),"$1$3$2");
|
||||
ta.value=ta.value.replace(new RegExp("(<script[^>]*>[^"+cc+"]*?)("+cc+")([^"+cc+"]*?</script>)"),"$1$3$2");
|
||||
ta.value=ta.value.replace(new RegExp("^([^"+cc+"]*)("+cc+")([^"+cc+"]*<body[^>]*>)(.*?)"),"$1$3$2$4");
|
||||
}else{
|
||||
var sel=this.getSelection();
|
||||
sel.getRangeAt(0).insertNode(this._doc.createTextNode(cc));
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
};
|
||||
Xinha.prototype.findCC=function(_5a){
|
||||
if(_5a=="textarea"){
|
||||
var ta=this._textArea;
|
||||
var pos=ta.value.indexOf(this.cc);
|
||||
if(pos==-1){
|
||||
return;
|
||||
}
|
||||
var end=pos+this.cc.length;
|
||||
var _5e=ta.value.substring(0,pos);
|
||||
var _5f=ta.value.substring(end,ta.value.length);
|
||||
ta.value=_5e;
|
||||
ta.scrollTop=ta.scrollHeight;
|
||||
var _60=ta.scrollTop;
|
||||
ta.value+=_5f;
|
||||
ta.setSelectionRange(pos,pos);
|
||||
ta.focus();
|
||||
ta.scrollTop=_60;
|
||||
}else{
|
||||
try{
|
||||
var doc=this._doc;
|
||||
doc.body.innerHTML=doc.body.innerHTML.replace(new RegExp(this.cc),"<span id=\"XinhaEditingPostion\"></span>");
|
||||
var _62=doc.getElementById("XinhaEditingPostion");
|
||||
this.selectNodeContents(_62);
|
||||
_62.scrollIntoView(true);
|
||||
_62.parentNode.removeChild(_62);
|
||||
this._iframe.contentWindow.focus();
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
}
|
||||
};
|
||||
Xinha.prototype._standardToggleBorders=Xinha.prototype._toggleBorders;
|
||||
Xinha.prototype._toggleBorders=function(){
|
||||
var _63=this._standardToggleBorders();
|
||||
var _64=this._doc.getElementsByTagName("TABLE");
|
||||
for(var i=0;i<_64.length;i++){
|
||||
_64[i].style.display="none";
|
||||
_64[i].style.display="table";
|
||||
}
|
||||
return _63;
|
||||
};
|
||||
Xinha.getDoctype=function(doc){
|
||||
var d="";
|
||||
if(doc.doctype){
|
||||
d+="<!DOCTYPE "+doc.doctype.name+" PUBLIC ";
|
||||
d+=doc.doctype.publicId?"\""+doc.doctype.publicId+"\"":"";
|
||||
d+=doc.doctype.systemId?" \""+doc.doctype.systemId+"\"":"";
|
||||
d+=">";
|
||||
}
|
||||
return d;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/Gecko/paraHandlerBest.js */
|
||||
EnterParagraphs._pluginInfo={name:"EnterParagraphs",version:"1.0",developer:"Adam Wright",developer_url:"http://www.hipikat.org/",sponsor:"The University of Western Australia",sponsor_url:"http://www.uwa.edu.au/",license:"htmlArea"};
|
||||
EnterParagraphs.prototype._whiteSpace=/^\s*$/;
|
||||
EnterParagraphs.prototype._pExclusions=/^(address|blockquote|body|dd|div|dl|dt|fieldset|form|h1|h2|h3|h4|h5|h6|hr|li|noscript|ol|p|pre|table|ul)$/i;
|
||||
EnterParagraphs.prototype._pContainers=/^(body|del|div|fieldset|form|ins|map|noscript|object|td|th)$/i;
|
||||
EnterParagraphs.prototype._pBreak=/^(address|pre|blockquote)$/i;
|
||||
EnterParagraphs.prototype._permEmpty=/^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param)$/i;
|
||||
EnterParagraphs.prototype._elemSolid=/^(applet|br|button|hr|img|input|table)$/i;
|
||||
EnterParagraphs.prototype._pifySibling=/^(address|blockquote|del|div|dl|fieldset|form|h1|h2|h3|h4|h5|h6|hr|ins|map|noscript|object|ol|p|pre|table|ul|)$/i;
|
||||
EnterParagraphs.prototype._pifyForced=/^(ul|ol|dl|table)$/i;
|
||||
EnterParagraphs.prototype._pifyParent=/^(dd|dt|li|td|th|tr)$/i;
|
||||
function EnterParagraphs(_1){
|
||||
this.editor=_1;
|
||||
if(Xinha.is_gecko){
|
||||
this.onKeyPress=this.__onKeyPress;
|
||||
}
|
||||
}
|
||||
EnterParagraphs.prototype.name="EnterParagraphs";
|
||||
EnterParagraphs.prototype.insertAdjacentElement=function(_2,_3,el){
|
||||
if(_3=="BeforeBegin"){
|
||||
_2.parentNode.insertBefore(el,_2);
|
||||
}else{
|
||||
if(_3=="AfterEnd"){
|
||||
_2.nextSibling?_2.parentNode.insertBefore(el,_2.nextSibling):_2.parentNode.appendChild(el);
|
||||
}else{
|
||||
if(_3=="AfterBegin"&&_2.firstChild){
|
||||
_2.insertBefore(el,_2.firstChild);
|
||||
}else{
|
||||
if(_3=="BeforeEnd"||_3=="AfterBegin"){
|
||||
_2.appendChild(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
EnterParagraphs.prototype.forEachNodeUnder=function(_5,_6,_7,_8){
|
||||
var _9,end;
|
||||
if(_5.nodeType==11&&_5.firstChild){
|
||||
_9=_5.firstChild;
|
||||
end=_5.lastChild;
|
||||
}else{
|
||||
_9=end=_5;
|
||||
}
|
||||
while(end.lastChild){
|
||||
end=end.lastChild;
|
||||
}
|
||||
return this.forEachNode(_9,end,_6,_7,_8);
|
||||
};
|
||||
EnterParagraphs.prototype.forEachNode=function(_a,_b,_c,_d,_e){
|
||||
var _f=function(_10,_11){
|
||||
return (_11=="ltr"?_10.nextSibling:_10.previousSibling);
|
||||
};
|
||||
var _12=function(_13,_14){
|
||||
return (_14=="ltr"?_13.firstChild:_13.lastChild);
|
||||
};
|
||||
var _15,lookup,fnReturnVal;
|
||||
var _16=_e;
|
||||
var _17=false;
|
||||
while(_15!=_d=="ltr"?_b:_a){
|
||||
if(!_15){
|
||||
_15=_d=="ltr"?_a:_b;
|
||||
}else{
|
||||
if(_12(_15,_d)){
|
||||
_15=_12(_15,_d);
|
||||
}else{
|
||||
if(_f(_15,_d)){
|
||||
_15=_f(_15,_d);
|
||||
}else{
|
||||
lookup=_15;
|
||||
while(!_f(lookup,_d)&&lookup!=(_d=="ltr"?_b:_a)){
|
||||
lookup=lookup.parentNode;
|
||||
}
|
||||
_15=(_f(lookup,_d)?_f(lookup,_d):lookup);
|
||||
}
|
||||
}
|
||||
}
|
||||
_17=(_15==(_d=="ltr"?_b:_a));
|
||||
switch(_c){
|
||||
case "cullids":
|
||||
fnReturnVal=this._fenCullIds(_15,_16);
|
||||
break;
|
||||
case "find_fill":
|
||||
fnReturnVal=this._fenEmptySet(_15,_16,_c,_17);
|
||||
break;
|
||||
case "find_cursorpoint":
|
||||
fnReturnVal=this._fenEmptySet(_15,_16,_c,_17);
|
||||
break;
|
||||
}
|
||||
if(fnReturnVal[0]){
|
||||
return fnReturnVal[1];
|
||||
}
|
||||
if(_17){
|
||||
break;
|
||||
}
|
||||
if(fnReturnVal[1]){
|
||||
_16=fnReturnVal[1];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
EnterParagraphs.prototype._fenEmptySet=function(_18,_19,_1a,_1b){
|
||||
if(!_19&&!_18.firstChild){
|
||||
_19=_18;
|
||||
}
|
||||
if((_18.nodeType==1&&this._elemSolid.test(_18.nodeName))||(_18.nodeType==3&&!this._whiteSpace.test(_18.nodeValue))||(_18.nodeType!=1&&_18.nodeType!=3)){
|
||||
switch(_1a){
|
||||
case "find_fill":
|
||||
return new Array(true,false);
|
||||
break;
|
||||
case "find_cursorpoint":
|
||||
return new Array(true,_18);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_1b){
|
||||
return new Array(true,_19);
|
||||
}
|
||||
return new Array(false,_19);
|
||||
};
|
||||
EnterParagraphs.prototype._fenCullIds=function(_1c,_1d,_1e){
|
||||
if(_1d.id){
|
||||
_1e[_1d.id]?_1d.id="":_1e[_1d.id]=true;
|
||||
}
|
||||
return new Array(false,_1e);
|
||||
};
|
||||
EnterParagraphs.prototype.processSide=function(rng,_20){
|
||||
var _21=function(_22,_23){
|
||||
return (_23=="left"?_22.previousSibling:_22.nextSibling);
|
||||
};
|
||||
var _24=_20=="left"?rng.startContainer:rng.endContainer;
|
||||
var _25=_20=="left"?rng.startOffset:rng.endOffset;
|
||||
var _26,start=_24;
|
||||
while(start.nodeType==1&&!this._permEmpty.test(start.nodeName)){
|
||||
start=(_25?start.lastChild:start.firstChild);
|
||||
}
|
||||
while(_26=_26?(_21(_26,_20)?_21(_26,_20):_26.parentNode):start){
|
||||
if(_21(_26,_20)){
|
||||
if(this._pExclusions.test(_21(_26,_20).nodeName)){
|
||||
return this.processRng(rng,_20,_26,_21(_26,_20),(_20=="left"?"AfterEnd":"BeforeBegin"),true,false);
|
||||
}
|
||||
}else{
|
||||
if(this._pContainers.test(_26.parentNode.nodeName)){
|
||||
return this.processRng(rng,_20,_26,_26.parentNode,(_20=="left"?"AfterBegin":"BeforeEnd"),true,false);
|
||||
}else{
|
||||
if(this._pExclusions.test(_26.parentNode.nodeName)){
|
||||
if(this._pBreak.test(_26.parentNode.nodeName)){
|
||||
return this.processRng(rng,_20,_26,_26.parentNode,(_20=="left"?"AfterBegin":"BeforeEnd"),false,(_20=="left"?true:false));
|
||||
}else{
|
||||
return this.processRng(rng,_20,(_26=_26.parentNode),(_21(_26,_20)?_21(_26,_20):_26.parentNode),(_21(_26,_20)?(_20=="left"?"AfterEnd":"BeforeBegin"):(_20=="left"?"AfterBegin":"BeforeEnd")),false,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
EnterParagraphs.prototype.processRng=function(rng,_28,_29,_2a,_2b,_2c,_2d){
|
||||
var _2e=_28=="left"?rng.startContainer:rng.endContainer;
|
||||
var _2f=_28=="left"?rng.startOffset:rng.endOffset;
|
||||
var _30=this.editor;
|
||||
var _31=_30._doc.createRange();
|
||||
_31.selectNode(_29);
|
||||
if(_28=="left"){
|
||||
_31.setEnd(_2e,_2f);
|
||||
rng.setStart(_31.startContainer,_31.startOffset);
|
||||
}else{
|
||||
if(_28=="right"){
|
||||
_31.setStart(_2e,_2f);
|
||||
rng.setEnd(_31.endContainer,_31.endOffset);
|
||||
}
|
||||
}
|
||||
var cnt=_31.cloneContents();
|
||||
this.forEachNodeUnder(cnt,"cullids","ltr",this.takenIds,false,false);
|
||||
var _33,pifyOffset,fill;
|
||||
_33=_28=="left"?(_31.endContainer.nodeType==3?true:false):(_31.startContainer.nodeType==3?false:true);
|
||||
pifyOffset=_33?_31.startOffset:_31.endOffset;
|
||||
_33=_33?_31.startContainer:_31.endContainer;
|
||||
if(this._pifyParent.test(_33.nodeName)&&_33.parentNode.childNodes.item(0)==_33){
|
||||
while(!this._pifySibling.test(_33.nodeName)){
|
||||
_33=_33.parentNode;
|
||||
}
|
||||
}
|
||||
if(cnt.nodeType==11&&!cnt.firstChild){
|
||||
if(_33.nodeName!="BODY"||(_33.nodeName=="BODY"&&pifyOffset!=0)){
|
||||
cnt.appendChild(_30._doc.createElement(_33.nodeName));
|
||||
}
|
||||
}
|
||||
fill=this.forEachNodeUnder(cnt,"find_fill","ltr",false);
|
||||
if(fill&&this._pifySibling.test(_33.nodeName)&&((pifyOffset==0)||(pifyOffset==1&&this._pifyForced.test(_33.nodeName)))){
|
||||
_29=_30._doc.createElement("p");
|
||||
_29.innerHTML=" ";
|
||||
if((_28=="left")&&_33.previousSibling){
|
||||
return new Array(_33.previousSibling,"AfterEnd",_29);
|
||||
}else{
|
||||
if((_28=="right")&&_33.nextSibling){
|
||||
return new Array(_33.nextSibling,"BeforeBegin",_29);
|
||||
}else{
|
||||
return new Array(_33.parentNode,(_28=="left"?"AfterBegin":"BeforeEnd"),_29);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(fill){
|
||||
if(fill.nodeType==3){
|
||||
fill=_30._doc.createDocumentFragment();
|
||||
}
|
||||
if((fill.nodeType==1&&!this._elemSolid.test())||fill.nodeType==11){
|
||||
var _34=_30._doc.createElement("p");
|
||||
_34.innerHTML=" ";
|
||||
fill.appendChild(_34);
|
||||
}else{
|
||||
var _34=_30._doc.createElement("p");
|
||||
_34.innerHTML=" ";
|
||||
fill.parentNode.insertBefore(parentNode,fill);
|
||||
}
|
||||
}
|
||||
if(fill){
|
||||
_29=fill;
|
||||
}else{
|
||||
_29=(_2c||(cnt.nodeType==11&&!cnt.firstChild))?_30._doc.createElement("p"):_30._doc.createDocumentFragment();
|
||||
_29.appendChild(cnt);
|
||||
}
|
||||
if(_2d){
|
||||
_29.appendChild(_30._doc.createElement("br"));
|
||||
}
|
||||
return new Array(_2a,_2b,_29);
|
||||
};
|
||||
EnterParagraphs.prototype.isNormalListItem=function(rng){
|
||||
var _36,listNode;
|
||||
_36=rng.startContainer;
|
||||
if((typeof _36.nodeName!="undefined")&&(_36.nodeName.toLowerCase()=="li")){
|
||||
listNode=_36;
|
||||
}else{
|
||||
if((typeof _36.parentNode!="undefined")&&(typeof _36.parentNode.nodeName!="undefined")&&(_36.parentNode.nodeName.toLowerCase()=="li")){
|
||||
listNode=_36.parentNode;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!listNode.previousSibling){
|
||||
if(rng.startOffset==0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
EnterParagraphs.prototype.__onKeyPress=function(ev){
|
||||
if(ev.keyCode==13&&!ev.shiftKey&&this.editor._iframe.contentWindow.getSelection){
|
||||
return this.handleEnter(ev);
|
||||
}
|
||||
};
|
||||
EnterParagraphs.prototype.handleEnter=function(ev){
|
||||
var _39;
|
||||
var sel=this.editor.getSelection();
|
||||
var rng=this.editor.createRange(sel);
|
||||
if(this.isNormalListItem(rng)){
|
||||
return true;
|
||||
}
|
||||
this.takenIds=new Object();
|
||||
var _3c=this.processSide(rng,"left");
|
||||
var _3d=this.processSide(rng,"right");
|
||||
_39=_3d[2];
|
||||
sel.removeAllRanges();
|
||||
rng.deleteContents();
|
||||
var _3e=this.forEachNodeUnder(_39,"find_cursorpoint","ltr",false,true);
|
||||
if(!_3e){
|
||||
alert("INTERNAL ERROR - could not find place to put cursor after ENTER");
|
||||
}
|
||||
if(_3c){
|
||||
this.insertAdjacentElement(_3c[0],_3c[1],_3c[2]);
|
||||
}
|
||||
if(_3d&&_3d.nodeType!=1){
|
||||
this.insertAdjacentElement(_3d[0],_3d[1],_3d[2]);
|
||||
}
|
||||
if((_3e)&&(this._permEmpty.test(_3e.nodeName))){
|
||||
var _3f=0;
|
||||
while(_3e.parentNode.childNodes.item(_3f)!=_3e){
|
||||
_3f++;
|
||||
}
|
||||
sel.collapse(_3e.parentNode,_3f);
|
||||
}else{
|
||||
try{
|
||||
sel.collapse(_3e,0);
|
||||
if(_3e.nodeType==3){
|
||||
_3e=_3e.parentNode;
|
||||
}
|
||||
this.editor.scrollToElement(_3e);
|
||||
}
|
||||
catch(e){
|
||||
}
|
||||
}
|
||||
this.editor.updateToolbar();
|
||||
Xinha._stopEvent(ev);
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user