?? editor.js
字號:
catch(e){}},AddHeight:function(){var h=this.EditorWindow.offsetHeight+this.StepHeight;this.EditorWindow.style.height=h+'px';if(Browser.IsSafari)this.Resize();},MinusHeight:function(){var h=this.EditorWindow.offsetHeight;if(h-this.StepHeight<this.MinHeight){h=this.MinHeight;}
else{h-=this.StepHeight;}
this.EditorWindow.style.height=h+'px';if(Browser.IsSafari)this.Resize();},SetHtml:function(html){this.CreateEditorArea(html);this.EditType=Config.WYSIWYG;this.ChangeStateAndButton(Config.WYSIWYG);},SetText:function(text){this.CreateTextArea(text,Config.XHTML);},GetSource:function(requireHtml){var str;switch(this.EditType){case Config.WYSIWYG:if(requireHtml||this.AllowHTML)
str=UBB.imageHTMLUrlToSign(UBB.multimediaHtmlToUbb(this.GetXhtmlFromHtml()));else
str=this.GetUBBFromXHtml(false);break;case Config.XHTML:if(requireHtml||this.AllowHTML)
str=this.GetTextContent();else
str=this.GetUBBFromXHtml(true);break;case Config.UBB:if(!requireHtml&&this.AllowUBB)
str=this.GetTextContent();else
str=this.GetXHtmlFromUBB(false);break;}
return str;},_GetSource:function(){var str;switch(this.EditType){case Config.WYSIWYG:if(this.TMode==Config.UBB)
str=this.GetUBBFromXHtml(false);else
str=UBB.imageUBBUrlToSign(this.GetXhtmlFromHtml());break;case Config.XHTML:if(this.TMode==Config.UBB)
str=this.GetUBBFromXHtml(true);else
str=this.GetTextContent();break;case Config.UBB:if(this.TMode==Config.UBB)
str=this.GetTextContent();else
str=this.GetXHtmlFromUBB(false);break;}
return str;},GetHtmlSource:function(){return UBB.imageHTMLSignToUrl(this.GetSource(true));},GetXhtmlFromHtml:function(){cXml.HtmlToXHtml(this.Document.body);var content=cXml.GetXmlString().replace(Config.NotAllowHtmlTag(),'').replace(/(<br[^\>]*?>)/gi,'$1\r\n');return content;},GetUBBFromXHtml:function(isXHtml){var html='';if(isXHtml)
html=this.GetTextContent();else
html=this.GetXhtmlFromHtml();html=html.replace(/\r|\n/gi,'')
return UBB.imageUBBUrlToSign(UBB.xhtmlToUbb(UBB.multimediaHtmlToUbb(html)));},GetXHtmlFromUBB:function(isXHTML){var str=UBB.ubbToXhtml(this.GetTextContent());if(isXHTML){str=UBB.imageHTMLUrlToSign(str).replace(/(<br[^\>]*?>)/gi,'$1\r\n');}
return str;},GetHtmlContent:function(){return this.Document.body.innerHTML;},GetTextContent:function(){try{return this.TextArea.value;}
catch(e){return'';}},UpdateTextField:function(only){var value=this.GetSource();if(value==this.TextField.value)return;var type;if(this.AllowHTML&&this.AllowUBB){type=this.EditType==Config.UBB?'ubb':'html';if(this.EditorType!=Config.UBB){value=UBB.someXhtmlToUbb(value);value=UBB.codeXhtmlToUbb(value);}}
else if(this.AllowHTML)
type='html';else
type='ubb';this.EditorType.value=type;this.TextField.value=value;if(only)return;if(this.TempValue.type!=this.type){var _value=this.TempValue.first;if(this.type==Config.UBB)
_value=UBB.xhtmlToUbb(_value);this.TempValue.first=_value;}
this.TempValue.type=type=='html'?Config.XHTML:Config.UBB;if(this.TempValue.first==''&&this.TempValue.first!=this.TempValue.second)
this.TempValue.first=this.TempValue.second;this.TempValue.second=value;this.DisplayTip();this.EditorObj.AfterChange({DMode:this.EditType,AllowHTML:this.AllowHTML,AllowUBB:this.AllowUBB},this.GetHtmlSource());},DisplayTip:function(){var isDisplay;if(this.TempValue.second=='')isDisplay=false;else if(this.TempValue.first=='')isDisplay=true;else isDisplay=this.TempValue.second!=this.OriginValue;this.EditorObj.Submitting(!isDisplay);},isWYSIWYG:function(){return this.EditType==Config.WYSIWYG;},isUBB:function(){return this.EditType==Config.UBB;},isXHTML:function(){return this.EditType==Config.XHTML;},ChangeState:function(type){var content;this.IsSwitch=false;if(type==Config.WYSIWYG&&this.EditType!=Config.WYSIWYG){this.IsSwitch=true;if(this.EditType==Config.UBB){content=this.GetXHtmlFromUBB(false);}
else{content=this.GetTextContent();}
content=UBB.imageHTMLSignToUrl(content)
this.CreateEditorArea(UBB.multimediaUbbToHtmlView(content,false));}
else if(type==Config.XHTML&&this.EditType!=Config.XHTML){if(!this.AllowHTML)return false;if(this.EditType==Config.UBB){content=this.GetXHtmlFromUBB(true);}
else{if(!this.JudgeNotAllowHtmlTag(this.Document.body.innerHTML))return false;content=UBB.imageHTMLUrlToSign(UBB.multimediaHtmlToUbb(this.GetXhtmlFromHtml(false)));}
this.TextRange=null;this.CreateTextArea(content,type);this.SelectOneTextArea();}
else if(type==Config.UBB&&this.EditType!=Config.UBB){if(!this.AllowUBB)return false;if(this.EditType==Config.XHTML){content=this.GetUBBFromXHtml(true);}
else{if(!this.JudgeNotAllowHtmlTag(this.Document.body.innerHTML))return false;content=UBB.imageUBBUrlToSign(this.GetUBBFromXHtml(false));}
this.TextRange=null;this.CreateTextArea(content,type);this.TextAreaBindEvent();}
this.EditType=type;Toolbar.responseAll(type==Config.XHTML);this.EditorObj.AfterChange({DMode:type,AllowHTML:this.AllowHTML,AllowUBB:this.AllowUBB});this.Resize();return true;},ChangeStateAndButton:function(type){type=type.toLowerCase();this.ChangeState(type);switch(type){case Config.WYSIWYG:Toolbar.wysiwygClick();break;case Config.XHTML:this.AllowHTML&&Toolbar.xhtmlClick();break;case Config.UBB:this.AllowUBB&&Toolbar.ubbClick();break;}},JudgeNotAllowHtmlTag:function(content){if(Config.NotAllowHtmlTag().test(content)){return confirm('內容包含不允許的標簽。\n是否繼續轉換?');}
return true;},GetRange:function(){if(Browser.IsIE){this.SelectRange=this.Document.selection;this.TextRange=this.SelectRange.createRange();}
else{this.SelectRange=this.Window.getSelection();}
return this.SelectRange;},GetTextRange:function(){if(Browser.IsIE){this.TextRange=document.selection.createRange();}
else{this.TextRangeStart=this.TextArea.selectionStart;this.TextRangeEnd=this.TextArea.selectionEnd;}
return this.TextRange;},SelectTextRange:function(isCollapse){if(!Browser.IsIE)return;if(this.EditType!=Config.WYSIWYG)return;try{if(this.TextRange){this.TextRange.collapse(false);isCollapse&&this.TextRange.select();}
else{this.Focus();}}
catch(e){}},SetStyle:function(type,value){var _status;if(!Browser.IsIELike&&type=='HiliteColor'){this.SetStyle('styleWithCSS',true);}
try{this.Focus();_status=this.Document.execCommand(type,false,value);}
catch(e){}
if(!Browser.IsIELike&&type=='HiliteColor'){this.SetStyle('styleWithCSS',false);}
this.SelectTextRange();return _status;},SetUBBStyle:function(){var contents=arguments;var l=contents.length;var t=this.TextArea;var content;var _content=content=Browser.IsIE?(this.TextRange?this.TextRange.text:''):t.value.substring(this.TextRangeStart,this.TextRangeEnd)
var index=contents[0].indexOf('\x01');content=contents[0].replace(/\x01/g,content||contents[1]||'');for(var i=1;i<l;i++){content=content.replace(new RegExp('\\x0'+(i+1),'g'),contents[i]);}
if(_content!='')index=0;if(Browser.IsIE){if(this.TextRange){this.TextRange.text=content;if(index>0)this.TextRange.move('character',index-content.length);this.TextRange.select();}
else{t.value+=content;}}
else{t.value=t.value.substring(0,this.TextRangeStart)+content+t.value.substring(this.TextRangeEnd);var start=index>0?this.TextRangeStart+index:this.TextRangeStart+content.length;t.setSelectionRange(start,start);this.TextRangeStart=this.TextRangeEnd=index>0?this.TextRangeStart+index:start;}
t.focus();this.GetTextRange();},InsertContent:function(content){if(this.EditType!=Config.WYSIWYG)return;if(Browser.IsIE)
this.InsertContentIE(content);else{var c=this.Document.createElement('span');this.Document.body.appendChild(c);c.innerHTML=content;try{this.InsertContentGecko(c);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -