⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editorcode_gecko.js

📁 通达网络办公 - Office Anywhere 2008 增强版100%源码(3.4.081216) 内含 通达OA2008增強版接近完美破解补丁20081216集 及 最新通达OA2008ADV(
💻 JS
📖 第 1 页 / 共 4 页
字号:
var TDEvents=function(A){this.Owner=A;this._RegisteredEvents={};};TDEvents.prototype.AttachEvent=function(A,B){var C;if (!(C=this._RegisteredEvents[A])) this._RegisteredEvents[A]=[B];else{if (C.IndexOf(B)==-1) C.push(B);}};TDEvents.prototype.FireEvent=function(A,B){var C=true;var D=this._RegisteredEvents[A];if (D){for (var i=0;i<D.length;i++){try{C=(D[i](this.Owner,B)&&C);}catch(e){if (e.number!=-2146823277) throw e;}}};return C;};
var TDDataProcessor=function(){};TDDataProcessor.prototype={ConvertToHtml:function(A){if (TDConfig.FullPage){TD.DocTypeDeclaration=A.match(TDRegexLib.DocTypeTag);if (!TDRegexLib.HasBodyTag.test(A)) A='<body>'+A+'</body>';if (!TDRegexLib.HtmlOpener.test(A)) A='<html dir="'+TDConfig.ContentLangDirection+'">'+A+'</html>';if (!TDRegexLib.HeadOpener.test(A)) A=A.replace(TDRegexLib.HtmlOpener,'$&<head><title></title></head>');return A;}else{var B=TDConfig.DocType+'<html dir="'+TDConfig.ContentLangDirection+'"';if (TDBrowserInfo.IsIE&&TDConfig.DocType.length>0&&!TDRegexLib.Html4DocType.test(TDConfig.DocType)) B+=' style="overflow-y: scroll"';B+='><head><title></title></head><body'+TDConfig.GetBodyAttributes()+'>'+A+'</body></html>';return B;}},ConvertToDataFormat:function(A,B,C,D){var E=TDXHtml.GetXHTML(A,!B,D);if (C&&TDRegexLib.EmptyOutParagraph.test(E)) return '';return E;},FixHtml:function(A){return A;}};
var TD={Name:TDURLParams['InstanceName'],Status:0,EditMode:0,Toolbar:null,HasFocus:false,DataProcessor:new TDDataProcessor(),AttachToOnSelectionChange:function(A){this.Events.AttachEvent('OnSelectionChange',A);},GetLinkedFieldValue:function(){return this.LinkedField.value;},GetParentForm:function(){return this.LinkedField.form;},StartupValue:'',IsDirty:function(){if (this.EditMode==1) return (this.StartupValue!=this.EditingArea.Textarea.value);else{if (!this.EditorDocument) return false;return (this.StartupValue!=this.EditorDocument.body.innerHTML);}},ResetIsDirty:function(){if (this.EditMode==1) this.StartupValue=this.EditingArea.Textarea.value;else if (this.EditorDocument.body) this.StartupValue=this.EditorDocument.body.innerHTML;},StartEditor:function(){this.TempBaseTag=TDConfig.BaseHref.length>0?'<base href="'+TDConfig.BaseHref+'" _temp="true"></base>':'';var A=TD.KeystrokeHandler=new TDKeystrokeHandler();A.OnKeystroke=_TD_KeystrokeHandler_OnKeystroke;A.SetKeystrokes(TDConfig.Keystrokes);if (TDBrowserInfo.IsIE7){if ((CTRL+86/*V*/) in A.Keystrokes) A.SetKeystrokes([CTRL+86,true]);if ((SHIFT+45/*INS*/) in A.Keystrokes) A.SetKeystrokes([SHIFT+45,true]);};A.SetKeystrokes([CTRL+8,true]);this.EditingArea=new TDEditingArea(document.getElementById('xEditingArea'));this.EditingArea.FFSpellChecker=TDConfig.FirefoxSpellChecker;this.SetData(this.GetLinkedFieldValue(),true);TDTools.AddEventListener(document,"keydown",this._TabKeyHandler);this.AttachToOnSelectionChange(_TD_PaddingNodeListener);if (TDBrowserInfo.IsGecko) this.AttachToOnSelectionChange(this._ExecCheckEmptyBlock);},Focus:function(){TD.EditingArea.Focus();},SetStatus:function(A){this.Status=A;if (A==1){TDFocusManager.AddWindow(window,true);if (TDBrowserInfo.IsIE) TDFocusManager.AddWindow(window.frameElement,true);if (TDConfig.StartupFocus) TD.Focus();};this.Events.FireEvent('OnStatusChange',A);},FixBody:function(){var A=TDConfig.EnterMode;if (A!='p'&&A!='div') return;var B=this.EditorDocument;if (!B) return;var C=B.body;if (!C) return;TDDomTools.TrimNode(C);var D=C.firstChild;var E;while (D){var F=false;switch (D.nodeType){case 1:if (!TDListsLib.BlockElements[D.nodeName.toLowerCase()]&&!D.getAttribute('_fakelement')&&D.getAttribute('_moz_dirty')==null) F=true;break;case 3:if (E||D.nodeValue.Trim().length>0) F=true;};if (F){var G=D.parentNode;if (!E) E=G.insertBefore(B.createElement(A),D);E.appendChild(G.removeChild(D));D=E.nextSibling;}else{if (E){TDDomTools.TrimNode(E);E=null;};D=D.nextSibling;}};if (E) TDDomTools.TrimNode(E);},GetData:function(A){if (TD.EditMode==1) return TD.EditingArea.Textarea.value;this.FixBody();var B=TD.EditorDocument;if (!B) return null;var C=TDConfig.FullPage;var D=TD.DataProcessor.ConvertToDataFormat(C?B.documentElement:B.body,!C,TDConfig.IgnoreEmptyParagraphValue,A);D=TD.ProtectEventsRestore(D);if (TDBrowserInfo.IsIE) D=D.replace(TDRegexLib.ToReplace,'$1');if (C){if (TD.DocTypeDeclaration&&TD.DocTypeDeclaration.length>0) D=TD.DocTypeDeclaration+'\n'+D;if (TD.XmlDeclaration&&TD.XmlDeclaration.length>0) D=TD.XmlDeclaration+'\n'+D;};return TDConfig.ProtectedSource.Revert(D);},UpdateLinkedField:function(){var A=TD.GetXHTML(TDConfig.FormatOutput);if (TDConfig.HtmlEncodeOutput) A=TDTools.HTMLEncode(A);TD.LinkedField.value=A;TD.Events.FireEvent('OnAfterLinkedFieldUpdate');},RegisteredDoubleClickHandlers:{},OnDoubleClick:function(A){var B=TD.RegisteredDoubleClickHandlers[A.tagName];if (B) B(A);},RegisterDoubleClickHandler:function(A,B){TD.RegisteredDoubleClickHandlers[B.toUpperCase()]=A;},OnAfterSetHTML:function(){TDDocumentProcessor.Process(TD.EditorDocument);TDUndo.SaveUndoStep();TD.Events.FireEvent('OnSelectionChange');TD.Events.FireEvent('OnAfterSetHTML');},ProtectUrls:function(A){A=A.replace(TDRegexLib.ProtectUrlsA,'$& _savedurl=$1');A=A.replace(TDRegexLib.ProtectUrlsImg,'$& _savedurl=$1');A=A.replace(TDRegexLib.ProtectUrlsArea,'$& _savedurl=$1');return A;},ProtectEvents:function(A){return A.replace(TDRegexLib.TagsWithEvent,_TD_ProtectEvents_ReplaceTags);},ProtectEventsRestore:function(A){return A.replace(TDRegexLib.ProtectedEvents,_TD_ProtectEvents_RestoreEvents);},ProtectTags:function(A){var B=TDConfig.ProtectedTags;if (TDBrowserInfo.IsIE) B+=B.length>0?'|ABBR|XML|EMBED':'ABBR|XML|EMBED';var C;if (B.length>0){C=new RegExp('<('+B+')(?!\w|:)','gi');A=A.replace(C,'<TD:$1');C=new RegExp('<\/('+B+')>','gi');A=A.replace(C,'<\/TD:$1>');};B='META';if (TDBrowserInfo.IsIE) B+='|HR';C=new RegExp('<(('+B+')(?=\\s|>|/)[\\s\\S]*?)/?>','gi');A=A.replace(C,'<TD:$1 />');return A;},SetData:function(A,B){this.EditingArea.Mode=TD.EditMode;if (TDBrowserInfo.IsIE&&TD.EditorDocument){TD.EditorDocument.detachEvent("onselectionchange",Doc_OnSelectionChange);};if (TD.EditMode==0){this._ForceResetIsDirty=(B===true);A=TDConfig.ProtectedSource.Protect(A);A=TD.DataProcessor.ConvertToHtml(A);A=A.replace(TDRegexLib.InvalidSelfCloseTags,'$1></$2>');A=TD.ProtectEvents(A);A=TD.ProtectUrls(A);A=TD.ProtectTags(A);if (TD.TempBaseTag.length>0&&!TDRegexLib.HasBaseTag.test(A)) A=A.replace(TDRegexLib.HeadOpener,'$&'+TD.TempBaseTag);var C='';if (!TDConfig.FullPage) C+=_TD_GetEditorAreaStyleTags();if (TDBrowserInfo.IsIE) C+=TD._GetBehaviorsStyle();else if (TDConfig.ShowBorders) C+='<link href="'+TDConfig.FullBasePath+'css/showtableborders_gecko.css" rel="stylesheet" type="text/css" _temp="true" />';C+='<link href="'+TDConfig.FullBasePath+'css/internal.css" rel="stylesheet" type="text/css" _temp="true" />';A=A.replace(TDRegexLib.HeadCloser,C+'$&');this.EditingArea.OnLoad=_TD_EditingArea_OnLoad;this.EditingArea.Start(A);}else{TD.EditorWindow=null;TD.EditorDocument=null;TDDomTools.PaddingNode=null;this.EditingArea.OnLoad=null;this.EditingArea.Start(A);this.EditingArea.Textarea._TDShowContextMenu=true;TD.EnterKeyHandler=null;if (B) this.ResetIsDirty();TD.KeystrokeHandler.AttachToElement(this.EditingArea.Textarea);this.EditingArea.Textarea.focus();TD.Events.FireEvent('OnAfterSetHTML');};if (TDBrowserInfo.IsGecko) window.onresize();},HasFocus:false,RedirectNamedCommands:{},ExecuteNamedCommand:function(A,B,C,D){if (!D) TDUndo.SaveUndoStep();if (!C&&TD.RedirectNamedCommands[A]!=null) TD.ExecuteRedirectedNamedCommand(A,B);else{TD.Focus();TD.EditorDocument.execCommand(A,false,B);TD.Events.FireEvent('OnSelectionChange');};if (!D) TDUndo.SaveUndoStep();},GetNamedCommandState:function(A){try{if (TDBrowserInfo.IsSafari&&TD.EditorWindow&&A.IEquals('Paste')) return 0;if (!TD.EditorDocument.queryCommandEnabled(A)) return -1;else{return TD.EditorDocument.queryCommandState(A)?1:0;}}catch (e){return 0;}},GetNamedCommandValue:function(A){var B='';var C=TD.GetNamedCommandState(A);if (C==-1) return null;try{B=this.EditorDocument.queryCommandValue(A);}catch(e) {};return B?B:'';},Paste:function(A){if (TD.Status!=2||!TD.Events.FireEvent('OnPaste')) return false;return A||TD._ExecPaste();},PasteFromWord:function(){TDDialog.OpenDialog('TDDialog_Paste',TDLang.PasteFromWord,'dialog/paste.html',400,330,'Word');},Preview:function(){var A=TDConfig.ScreenWidth*0.8;var B=TDConfig.ScreenHeight*0.7;var C=(TDConfig.ScreenWidth-A)/2;var D=window.open('',null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+A+',height='+B+',left='+C);var E;if (TDConfig.FullPage){if (TD.TempBaseTag.length>0) E=TD.TempBaseTag+TD.GetXHTML();else E=TD.GetXHTML();}else{E=TDConfig.DocType+'<html dir="'+TDConfig.ContentLangDirection+'"><head>'+TD.TempBaseTag+'<title>'+TDLang.Preview+'</title>'+_TD_GetEditorAreaStyleTags()+'</head><body'+TDConfig.GetBodyAttributes()+'>'+TD.GetXHTML()+'</body></html>';};D.document.write(E);D.document.close();},SwitchEditMode:function(A){var B=(TD.EditMode==0);var C=TD.IsDirty();var D;if (B){TDCommands.GetCommand('ShowBlocks').SaveState();if (!A&&TDBrowserInfo.IsIE) TDUndo.SaveUndoStep();D=TD.GetXHTML(TDConfig.FormatSource);if (D==null) return false;}else D=this.EditingArea.Textarea.value;TD.EditMode=B?1:0;TD.SetData(D,!C);TD.Focus();TDTools.RunFunction(TD.ToolbarSet.RefreshModeState,TD.ToolbarSet);return true;},InsertElement:function(A){if (typeof A=='string') A=this.EditorDocument.createElement(A);var B=A.nodeName.toLowerCase();var C=new TDDomRange(this.EditorWindow);if (TDListsLib.BlockElements[B]!=null){C.SplitBlock();C.InsertNode(A);var D=TDDomTools.GetNextSourceElement(A,false,null,['hr','br','param','img','area','input']);if (!D&&TDConfig.EnterMode!='br'){D=this.EditorDocument.body.appendChild(this.EditorDocument.createElement(TDConfig.EnterMode));if (TDBrowserInfo.IsGeckoLike) TDTools.AppendBogusBr(D);};if (TDListsLib.EmptyElements[B]==null) C.MoveToElementEditStart(A);else if (D) C.MoveToElementEditStart(D);else C.MoveToPosition(A,4);if (TDBrowserInfo.IsGecko){if (D) D.scrollIntoView(false);A.scrollIntoView(false);}}else{C.MoveToSelection();C.DeleteContents();C.InsertNode(A);C.SetStart(A,4);C.SetEnd(A,4);};C.Select();C.Release();this.Focus();return A;},_InsertBlockElement:function(A){},_IsFunctionKey:function(A){if (A>=16&&A<=20) return true;if (A==27||(A>=33&&A<=40)) return true;if (A==45) return true;return false;},_KeyDownListener:function(A){if (!A) A=TD.EditorWindow.event;if (TD.EditorWindow){if (!TD._IsFunctionKey(A.keyCode)&&!(A.ctrlKey||A.metaKey)&&!(A.keyCode==46)) TD._KeyDownUndo();};return true;},_KeyDownUndo:function(){if (!TDUndo.Typing){TDUndo.SaveUndoStep();TDUndo.Typing=true;TD.Events.FireEvent("OnSelectionChange");};TDUndo.TypesCount++;TDUndo.Changed=1;if (TDUndo.TypesCount>TDUndo.MaxTypes){TDUndo.TypesCount=0;TDUndo.SaveUndoStep();}},_TabKeyHandler:function(A){if (!A) A=window.event;var B=A.keyCode;if (B==9&&TD.EditMode!=0){if (TDBrowserInfo.IsIE){var C=document.selection.createRange();if (C.parentElement()!=TD.EditingArea.Textarea) return true;C.text='\t';C.select();}else{var a=[];var D=TD.EditingArea.Textarea;var E=D.selectionStart;var F=D.selectionEnd;a.push(D.value.substr(0,E));a.push('\t');a.push(D.value.substr(F));D.value=a.join('');D.setSelectionRange(E+1,E+1);};if (A.preventDefault) return A.preventDefault();return A.returnValue=false;};return true;}};TD.Events=new TDEvents(TD);TD.GetHTML=TD.GetXHTML=TD.GetData;TD.SetHTML=TD.SetData;TD.InsertElementAndGetIt=TD.CreateElement=TD.InsertElement;function _TD_ProtectEvents_ReplaceTags(A){return A.replace(TDRegexLib.EventAttributes,_TD_ProtectEvents_ReplaceEvents);};function _TD_ProtectEvents_ReplaceEvents(A,B){return ' '+B+'_protectedatt="'+encodeURIComponent(A)+'"';};function _TD_ProtectEvents_RestoreEvents(A,B){return decodeURIComponent(B);};function _TD_MouseEventsListener(A){if (!A) A=window.event;if (A.type=='mousedown') TD.MouseDownFlag=true;else if (A.type=='mouseup') TD.MouseDownFlag=false;else if (A.type=='mousemove') TD.Events.FireEvent('OnMouseMove',A);};function _TD_PaddingNodeListener(){if (TDConfig.EnterMode.IEquals('br')) return;TDDomTools.EnforcePaddingNode(TD.EditorDocument,TDConfig.EnterMode);if (!TDBrowserInfo.IsIE&&TDDomTools.PaddingNode){var A=TD.EditorWindow.getSelection();if (A&&A.rangeCount==1){var B=A.getRangeAt(0);if (B.collapsed&&B.startContainer==TD.EditorDocument.body&&B.startOffset==0){B.selectNodeContents(TDDomTools.PaddingNode);B.collapse(true);A.removeAllRanges();A.addRange(B);}}}else if (TDDomTools.PaddingNode){var C=TDSelection.GetParentElement();var D=TDDomTools.PaddingNode;if (C&&C.nodeName.IEquals('body')){if (TD.EditorDocument.body.childNodes.length==1&&TD.EditorDocument.body.firstChild==D){var B=TD.EditorDocument.body.createTextRange();var F=false;if (!D.childNodes.firstChild){D.appendChild(D.ownerDocument.createTextNode('\ufeff'));F=true;};B.moveToElementText(D);B.select();if (F) B.pasteHTML('');}}}};function _TD_EditingArea_OnLoad(){TD.EditorWindow=TD.EditingArea.Window;TD.EditorDocument=TD.EditingArea.Document;TD.InitializeBehaviors();TD.MouseDownFlag=false;TDTools.AddEventListener(TD.EditorDocument,'mousemove',_TD_MouseEventsListener);TDTools.AddEventListener(TD.EditorDocument,'mousedown',_TD_MouseEventsListener);TDTools.AddEventListener(TD.EditorDocument,'mouseup',_TD_MouseEventsListener);if (TDBrowserInfo.IsSafari){var A=function(evt){if (!(evt.ctrlKey||evt.metaKey)) return;if (TD.EditMode!=0) return;switch (evt.keyCode){case 89:TDUndo.Redo();break;case 90:TDUndo.Undo();break;}};TDTools.AddEventListener(TD.EditorDocument,'keyup',A);};TD.EnterKeyHandler=new TDEnterKey(TD.EditorWindow,TDConfig.EnterMode,TDConfig.ShiftEnterMode,TDConfig.TabSpaces);TD.KeystrokeHandler.AttachToElement(TD.EditorDocument);if (TD._ForceResetIsDirty) TD.ResetIsDirty();if (TDBrowserInfo.IsIE&&TD.HasFocus) TD.EditorDocument.body.setActive();TD.OnAfterSetHTML();TDCommands.GetCommand('ShowBlocks').RestoreState();if (TD.Status!=0) return;if (TDConfig.Debug) TDDebug._GetWindow();TD.SetStatus(1);};function _TD_GetEditorAreaStyleTags(){var A='';var B=TDConfig.EditorAreaCSS;var C=TDConfig.EditorAreaStyles;for (var i=0;i<B.length;i++) A+='<link href="'+B[i]+'" rel="stylesheet" type="text/css" />';if (C&&C.length>0) A+="<style>"+C+"</style>";return A;};function _TD_KeystrokeHandler_OnKeystroke(A,B){if (TD.Status!=2) return false;if (TD.EditMode==0){switch (B){case 'Paste':return!TD.Paste();case 'Cut':TDUndo.SaveUndoStep();return false;}}else{if (B.Equals('Paste','Undo','Redo','SelectAll','Cut')) return false;};var C=TD.Commands.GetCommand(B);return (C.Execute.apply(C,TDTools.ArgumentsToArray(arguments,2))!==false);};(function(){var A=window.parent.document;var B=A.getElementById(TD.Name);var i=0;while (B||i==0){if (B&&B.tagName.toLowerCase().Equals('input','textarea')){TD.LinkedField=B;break;};B=A.getElementsByName(TD.Name)[i++];}})();var TDTempBin={Elements:[],AddElement:function(A){var B=this.Elements.length;this.Elements[B]=A;return B;},RemoveElement:function(A){var e=this.Elements[A];this.Elements[A]=null;return e;},Reset:function(){var i=0;while (i<this.Elements.length) this.Elements[i++]=null;this.Elements.length=0;}};var TDFocusManager=TD.FocusManager={IsLocked:false,AddWindow:function(A,B){var C;if (TDBrowserInfo.IsIE) C=A.nodeType==1?A:A.frameElement?A.frameElement:A.document;else if (TDBrowserInfo.IsSafari) C=A;else C=A.document;TDTools.AddEventListener(C,'blur',TDFocusManager_Win_OnBlur);TDTools.AddEventListener(C,'focus',B?TDFocusManager_Win_OnFocus_Area:TDFocusManager_Win_OnFocus);},RemoveWindow:function(A){if (TDBrowserInfo.IsIE) oTarget=A.nodeType==1?A:A.frameElement?A.frameElement:A.document;else oTarget=A.document;TDTools.RemoveEventListener(oTarget,'blur',TDFocusManager_Win_OnBlur);TDTools.RemoveEventListener(oTarget,'focus',TDFocusManager_Win_OnFocus_Area);TDTools.RemoveEventListener(oTarget,'focus',TDFocusManager_Win_OnFocus);},Lock:function(){this.IsLocked=true;},Unlock:function(){if (this._HasPendingBlur) TDFocusManager._Timer=window.setTimeout(TDFocusManager_FireOnBlur,100);this.IsLocked=false;},_ResetTimer:function(){this._HasPendingBlur=false;if (this._Timer){window.clearTimeout(this._Timer);delete this._Timer;}}};function TDFocusManager_Win_OnBlur(){if (typeof(TD)!='undefined'&&TD.HasFocus){TDFocusManager._ResetTimer();TDFocusManager._Timer=window.setTimeout(TDFocusManager_FireOnBlur,100);}};function TDFocusManager_FireOnBlur(){if (TDFocusManager.IsLocked) TDFocusManager._HasPendingBlur=true;else{TD.HasFocus=false;TD.Events.FireEvent("OnBlur");}};function TDFocusManager_Win_OnFocus_Area(){TD.Focus();TDFocusManager_Win_OnFocus();};function TDFocusManager_Win_OnFocus(){TDFocusManager._ResetTimer();if (!TD.HasFocus&&!TDFocusManager.IsLocked){TD.HasFocus=true;TD.Events.FireEvent("OnFocus");}};
TD.Description="TDeditor for Gecko Browsers";TD.InitializeBehaviors=function(){if (TDBrowserInfo.IsGecko) Window_OnResize();TDFocusManager.AddWindow(this.EditorWindow);this.ExecOnSelectionChange=function(){TD.Events.FireEvent("OnSelectionChange");};this._ExecDrop=function(evt){if (TD.MouseDownFlag){TD.MouseDownFlag=false;return;};if (TDConfig.ForcePasteAsPlainText){if (evt.dataTransfer){var A=evt.dataTransfer.getData('Text');A=TDTools.HTMLEncode(A);A=TDTools.ProcessLineBreaks(window,TDConfig,A);TD.InsertHtml(A);}else if (TDConfig.ShowDropDialog) TD.PasteAsPlainText();}else if (TDConfig.ShowDropDialog) TDDialog.OpenDialog('TDDialog_Paste',TDLang.Paste,'dialog/paste.html',400,330,'Security');evt.preventDefault();evt.stopPropagation();};this._ExecCheckCaret=function(evt){if (TD.EditMode!=0) return;if (evt.type=='keypress'){var B=evt.keyCode;if (B<33||B>40) return;};var C=function(H){if (H.nodeType!=1) return false;var D=H.tagName.toLowerCase();return (TDListsLib.BlockElements[D]||TDListsLib.EmptyElements[D]);};var E=function(){var F=TD.EditorWindow.getSelection();var G=F.getRangeAt(0);if (!G||!G.collapsed) return;var H=G.endContainer;if (H.nodeType!=3) return;if (H.nodeValue.length!=G.endOffset) return;var I=H.parentNode.tagName.toLowerCase();if (!(I=='a'||(!(TDListsLib.BlockElements[I]||TDListsLib.NonEmptyBlockElements[I])&&B==35))) return;var J=TDTools.GetNextTextNode(H,H.parentNode,C);if (J) return;G=TD.EditorDocument.createRange();J=TDTools.GetNextTextNode(H,H.parentNode.parentNode,C);if (J){if (TDBrowserInfo.IsOpera&&B==37) return;G.setStart(J,0);G.setEnd(J,0);}else{while (H.parentNode&&H.parentNode!=TD.EditorDocument.body&&H.parentNode!=TD.EditorDocument.documentElement&&H==H.parentNode.lastChild&&(!TDListsLib.BlockElements[H.parentNode.tagName.toLowerCase()]&&!TDListsLib.NonEmptyBlockElements[H.parentNode.tagName.toLowerCase()])) H=H.parentNode;if (TDListsLib.BlockElements[I]||TDListsLib.EmptyElements[I]||H==TD.EditorDocument.body){G.setStart(H,H.childNodes.length);G.setEnd(H,H.childNodes.length);}else{var K=H.nextSibling;while (K){if (K.nodeType!=1){K=K.nextSibling;continue;};var L=K.tagName.toLowerCase();if (TDListsLib.BlockElements[L]||TDListsLib.EmptyElements[L]||TDListsLib.NonEmptyBlockElements[L]) break;K=K.nextSibling;};var M=TD.EditorDocument.createTextNode('');if (K) H.parentNode.insertBefore(M,K);else H.parentNode.appendChild(M);G.setStart(M,0);G.setEnd(M,0);}};F.removeAllRanges();F.addRange(G);TD.Events.FireEvent("OnSelectionChange");};setTimeout(E,1);};this.ExecOnSelectionChangeTimer=function(){if (TD.LastOnChangeTimer) window.clearTimeout(TD.LastOnChangeTimer);TD.LastOnChangeTimer=window.setTimeout(TD.ExecOnSelectionChange,100);};this.EditorDocument.addEventListener('mouseup',this.ExecOnSelectionChange,false);this.EditorDocument.addEventListener('keyup',this.ExecOnSelectionChangeTimer,false);this._DblClickListener=function(e){TD.OnDoubleClick(e.target);e.stopPropagation();};this.EditorDocument.addEventListener('dblclick',this._DblClickListener,true);this.EditorDocument.addEventListener('keydown',this._KeyDownListener,false);if (TDBrowserInfo.IsGecko){this.EditorWindow.addEventListener('dragdrop',this._ExecDrop,true);}else if (TDBrowserInfo.IsSafari){var N=function(evt){ if (!TD.MouseDownFlag) evt.returnValue=false;};this.EditorDocument.addEventListener('dragenter',N,true);this.EditorDocument.addEventListener('dragover',N,true);this.EditorDocument.addEventListener('drop',this._ExecDrop,true);this.EditorDocument.addEventListener('mousedown',function(ev){var O=ev.srcElement;if (O.nodeName.IEquals('IMG','HR','INPUT','TEXTAREA','SELECT')){TDSelection.SelectNode(O);}},true);this.EditorDocument.addEventListener('mouseup',function(ev){if (ev.srcElement.nodeName.IEquals('INPUT','TEXTAREA','SELECT')) ev.preventDefault()},true);this.EditorDocument.addEventListener('click',function(ev){if (ev.srcElement.nodeName.IEquals('INPUT','TEXTAREA','SELECT')) ev.preventDefault()},true);};if (TDBrowserInfo.IsGecko||TDBrowserInfo.IsOpera){this.EditorDocument.addEventListener('keypress',this._ExecCheckCaret,false);this.EditorDocument.addEventListener('click',this._ExecCheckCaret,false);};TD.ContextMenu._InnerContextMenu.SetMouseClickWindow(TD.EditorWindow);TD.ContextMenu._InnerContextMenu.AttachToElement(TD.EditorDocument);};TD.MakeEditable=function(){this.EditingArea.MakeEditable();};function Document_OnContextMenu(e){if (!e.target._TDShowContextMenu) e.preventDefault();};document.oncontextmenu=Document_OnContextMenu;TD._BaseGetNamedCommandState=TD.GetNamedCommandState;TD.GetNamedCommandState=function(A){switch (A){case 'Unlink':return TDSelection.HasAncestorNode('A')?0:-1;default:return TD._BaseGetNamedCommandState(A);}};TD.RedirectNamedCommands={Print:true,Paste:true,Cut:true,Copy:true};TD.ExecuteRedirectedNamedCommand=function(A,B){switch (A){case 'Print':TD.EditorWindow.print();break;case 'Paste':try{if (TDBrowserInfo.IsSafari) throw '';if (TD.Paste()) TD.ExecuteNamedCommand('Paste',null,true);}catch (e)	{ TDDialog.OpenDialog('TDDialog_Paste',TDLang.Paste,'dialog/paste.html',400,330,'Security');};break;case 'Cut':try			{ TD.ExecuteNamedCommand('Cut',null,true);}catch (e)	{ alert(TDLang.PasteErrorCut);};break;case 'Copy':try			{ TD.ExecuteNamedCommand('Copy',null,true);}catch (e)	{ alert(TDLang.PasteErrorCopy);};break;default:TD.ExecuteNamedCommand(A,B);}};TD._ExecPaste=function(){TDUndo.SaveUndoStep();if (TDConfig.ForcePasteAsPlainText){TD.PasteAsPlainText();return false;};return true;};TD.InsertHtml=function(A){A=TDConfig.ProtectedSource.Protect(A);A=TD.ProtectEvents(A);A=TD.ProtectUrls(A);A=TD.ProtectTags(A);TDUndo.SaveUndoStep();this.EditorDocument.execCommand('inserthtml',false,A);this.Focus();this.Events.FireEvent("OnSelectionChange");};TD.PasteAsPlainText=function(){TDTools.RunFunction(TDDialog.OpenDialog,TDDialog,['TDDialog_Paste',TDLang.PasteAsText,'dialog/paste.html',400,330,'PlainText']);};TD.GetClipboardHTML=function(){return '';};TD.CreateLink=function(A,B){var C=[];TD.ExecuteNamedCommand('Unlink',null,false,!!B);if (A.length>0){var D='javascript:void(0);/*'+(new Date().getTime())+'*/';TD.ExecuteNamedCommand('CreateLink',D,false,!!B);var E=this.EditorDocument.evaluate("//a[@href='"+D+"']",this.EditorDocument.body,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var i=0;i<E.snapshotLength;i++){var F=E.snapshotItem(i);F.href=A;if (D==F.innerHTML) F.innerHTML='';C.push(F);}};return C;};TD._FillEmptyBlock=function(A){if (!A||A.nodeType!=1) return;var B=A.tagName.toLowerCase();if (B!='p'&&B!='div') return;if (A.firstChild) return;TDTools.AppendBogusBr(A);};TD._ExecCheckEmptyBlock=function(){TD._FillEmptyBlock(TD.EditorDocument.body.firstChild);var A=TD.EditorWindow.getSelection();if (!A||A.rangeCount<1) return;var B=A.getRangeAt(0);TD._FillEmptyBlock(B.startContainer);};
var TDConfig=TD.Config={};if (document.location.protocol=='file:'){TDConfig.BasePath=decodeURIComponent(document.location.pathname.substr(1));TDConfig.BasePath=TDConfig.BasePath.replace(/\\/gi, '/');var sFullProtocol=document.location.href.match(/^(file\:\/{2,3})/)[1];if (TDBrowserInfo.IsOpera) sFullProtocol+='localhost/';TDConfig.BasePath=sFullProtocol+TDConfig.BasePath.substring(0,TDConfig.BasePath.lastIndexOf('/')+1);TDConfig.FullBasePath=TDConfig.BasePath;}else{TDConfig.BasePath=document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1);TDConfig.FullBasePath=document.location.protocol+'//'+document.location.host+TDConfig.BasePath;};TDConfig.EditorPath=TDConfig.BasePath.replace(/editor\/$/,'');try{TDConfig.ScreenWidth=screen.width;TDConfig.ScreenHeight=screen.height;}catch (e){TDConfig.ScreenWidth=800;TDConfig.ScreenHeight=600;};TDConfig.ProcessHiddenField=function(){this.PageConfig={};var A=window.parent.document.getElementById(TD.Name+'___Config');if (!A) return;var B=A.value.split('&');for (var i=0;i<B.length;i++){if (B[i].length==0) continue;var C=B[i].split('=');var D=decodeURIComponent(C[0]);var E=decodeURIComponent(C[1]);if (D=='CustomConfigurationsPath') TDConfig[D]=E;else if (E.toLowerCase()=="true") this.PageConfig[D]=true;else if (E.toLowerCase()=="false") this.PageConfig[D]=false;else if (E.length>0&&!isNaN(E)) this.PageConfig[D]=parseInt(E,10);else this.PageConfig[D]=E;}};function TDConfig_LoadPageConfig(){var A=TDConfig.PageConfig;for (var B in A) TDConfig[B]=A[B];};function TDConfig_PreProcess(){var A=TDConfig;if (A.AllowQueryStringDebug){try{if ((/debug=true/i).test(window.top.location.search)) A.Debug=true;}catch (e) {/*Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error).*/}};if (!A.PluginsPath.EndsWith('/')) A.PluginsPath+='/';if (typeof(A.EditorAreaCSS)=='string') A.EditorAreaCSS=A.EditorAreaCSS.split(',');var B=A.ToolbarComboPreviewCSS;if (!B||B.length==0) A.ToolbarComboPreviewCSS=A.EditorAreaCSS;else if (typeof(B)=='string') A.ToolbarComboPreviewCSS=[B];};TDConfig.ToolbarSets={};TDConfig.Plugins={};TDConfig.Plugins.Items=[];TDConfig.Plugins.Add=function(A,B,C){TDConfig.Plugins.Items.AddItem([A,B,C]);};TDConfig.ProtectedSource={};TDConfig.ProtectedSource._CodeTag=(new Date()).valueOf();TDConfig.ProtectedSource.RegexEntries=[/<!--[\s\S]*?-->/g,/<script[\s\S]*?<\/script>/gi,/<noscript[\s\S]*?<\/noscript>/gi,/<object[\s\S]+?<\/object>/gi];TDConfig.ProtectedSource.Add=function(A){this.RegexEntries.AddItem(A);};TDConfig.ProtectedSource.Protect=function(A){var B=this._CodeTag;function _Replace(protectedSource){var C=TDTempBin.AddElement(protectedSource);return '<!--{'+B+C+'}-->';};for (var i=0;i<this.RegexEntries.length;i++){A=A.replace(this.RegexEntries[i],_Replace);};return A;};TDConfig.ProtectedSource.Revert=function(A,B){function _Replace(m,opener,index){var C=B?TDTempBin.RemoveElement(index):TDTempBin.Elements[index];return TDConfig.ProtectedSource.Revert(C,B);};var D=new RegExp("(<|&lt;)!--\\{"+this._CodeTag+"(\\d+)\\}--(>|&gt;)","g");return A.replace(D,_Replace);};TDConfig.GetBodyAttributes=function(){var A='';if (this.BodyId&&this.BodyId.length>0) A+=' id="'+this.BodyId+'"';if (this.BodyClass&&this.BodyClass.length>0) A+=' class="'+this.BodyClass+'"';return A;};TDConfig.ApplyBodyAttributes=function(A){if (this.BodyId&&this.BodyId.length>0) A.id=TDConfig.BodyId;if (this.BodyClass&&this.BodyClass.length>0) A.className+=' '+TDConfig.BodyClass;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -