📄 richtext.js
字号:
}
current_tag = current_tag.parentNode;}
}; function rteBtnDeleteTableRow() { if (window.getSelection)
{ var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;}
else if (document.getSelection)
{ var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;}
else if (document.selection)
{ var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();}
current_tag = selected_obj; while(current_tag.tagName != "TABLE"){ if (current_tag.tagName == "TR") { RowIndex = current_tag.rowIndex;}
if (current_tag.tagName == "TBODY") { RowTotal = current_tag.parentNode.rows.length; var x=current_tag.parentNode; x.deleteRow(RowIndex);}
current_tag = current_tag.parentNode;}
}; function rteAction(ID) { rteHideMenus(); if (this.id != "editlink" && this.id != "insertflash"&& this.id != "edittable" && this.id != "createlink" && this.id != "insertimage" && this.id != "inserttable" && this.id != "insertrowbelow" && this.id != "insertrowabove" && this.id != "insertcolumnleft" && this.id != "insertcolumnright" && this.id != "deletecolumn" && this.id != "deleterow" && this.id != "insertform" && this.id != "form_checkbox" && this.id != "form_radio" && this.id != "form_dropdown" && this.id != "form_textarea" && this.id != "form_submit" && this.id != "form_image_submit" && this.id != "form_reset" && this.id != "form_hidden" && this.id != "form_password" && this.id != "form_textfield" && this.id != "spellcheck" && this.id != "printrte" && this.id != "aboutrte") { document.getElementById(rteName).contentWindow.document.execCommand(this.id, false, null); document.getElementById(this.id).className = "rtebtn4"; document.getElementById(this.id).onmouseout = rteBtnMouseDown; document.getElementById(rteName).contentWindow.focus();}
}; function startRTE(rtePreloadContent) { rteCSS = document.getElementById("preview_css").value; var kids = document.getElementsByTagName("FORM"); for (var i=0; i < kids.length; i++) { kids[i].onsubmit = rteFormHandler;}
document.getElementById(rteName).contentWindow.document.designMode = "on"; document.getElementById(rteFormName).value = rtePreloadContent; document.getElementById(rteName).contentWindow.document.open(); document.getElementById(rteName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+rteCSS+");</style></head><body>" + rtePreloadContent + "</body></html>"); document.getElementById(rteName).contentWindow.document.close(); if (document.all && !window.opera) { document.getElementById(rteName).contentWindow.document.attachEvent("onkeypress", rteSelection); document.getElementById(rteName).contentWindow.document.attachEvent("onclick", rteSelection); document.getElementById(rteName).contentWindow.document.attachEvent("onmouseup", rteSelection);} else { document.getElementById(rteName).contentWindow.document.execCommand("useCSS", false, null); document.getElementById(rteName).contentWindow.document.addEventListener("keypress", rteSelection, true); document.getElementById(rteName).contentWindow.document.addEventListener("click", rteSelection, true); document.getElementById(rteName).contentWindow.document.addEventListener("mouseup", rteSelection, true);}
rteSelection(); var kids = document.getElementsByTagName("DIV"); for (var i=0; i < kids.length; i++) { if(kids[i].className == "rtebtn6"){ kids[i].onmouseover = rteBtnMouseOverBottom; kids[i].onmouseout = rteBtnMouseOutBottom; kids[i].onmousedown = rteBtnMouseDownBottom; kids[i].onmouseup = rteBtnMouseUpBottom;}
}
}; function rteFormHandler() { if (document.getElementById(rteFormName).style.display == "")
{ var newHTML = getXHTML(trim(document.getElementById(rteFormName).value));}
else
{ var newHTML = getXHTML(trim(document.getElementById(rteName).contentWindow.document.body.innerHTML));}
pattern = /<div[^>]*border: 1px dotted red[^>]*>.*<\/form><\/div>/gi; matchesArray = newHTML.match(pattern); if (matchesArray != null)
{ for (i=0; i<matchesArray.length; i++){ pattern2 = /<div[^>]*border: 1px dotted red[^>]*>/gi; pattern3 = /<\/div>/gi; replacement = matchesArray[i]; replacement = replacement.replace(pattern2, ""); replacement = replacement.replace(pattern3, ""); if (document.getElementById(rteFormName).style.display == "")
{ newHTML = document.getElementById(rteFormName).value.replace(matchesArray[i], replacement);}
else
{ newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement);}
}
}
pattern = /<table[^>]*class=\"rte_tbl\"[^>]*>/gi; matchesArray = newHTML.match(pattern); if (matchesArray != null)
{ for (i=0; i<matchesArray.length; i++){ pattern2 = /class=\"rte_tbl\"/gi; replacement = matchesArray[i]; replacement = replacement.replace(pattern2, ""); newHTML = newHTML.replace(matchesArray[i], replacement);}
}
document.getElementById(rteFormName).value = newHTML; document.getElementById(rteName).contentWindow.document.body.innerHTML = newHTML;}; function rteFormHandler2() { if (document.getElementById(rteFormName).style.display == "")
{ var newHTML = document.getElementById(rteFormName).value;}
else
{ var newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML;}
pattern = /<form[^>]*>[^<]*<\/form>/gi; matchesArray = newHTML.match(pattern); if (matchesArray != null)
{ for (i=0; i<matchesArray.length; i++){ replacement = matchesArray[i]; replacement = replacement.replace(matchesArray[i], "<div style=\"border: 1px dotted red;\">" + matchesArray[i] + "</div>"); if (document.getElementById(rteFormName).style.display == "")
{ newHTML = document.getElementById(rteFormName).value.replace(matchesArray[i], replacement);}
else
{ newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement);}
}
}
pattern = /<table[^>]*border=\"0\"[^>]*>/gi; matchesArray = newHTML.match(pattern); if (matchesArray != null)
{ for (i=0; i<matchesArray.length; i++){ pattern2 = /border=\"0\"/gi; replacement = matchesArray[i]; replacement = replacement.replace(pattern2, "border=\"0\" class=\"rte_tbl\""); newHTML = newHTML.replace(matchesArray[i], replacement);}
}
if (document.getElementById(rteFormName).style.display == "")
{ document.getElementById(rteFormName).value = newHTML;}
else
{ document.getElementById(rteName).contentWindow.document.body.innerHTML = newHTML;}
}; function rteSelection() { rteHideMenus(); if (document.getElementById("rte_code_mode").className == "rtebtn9")
{ document.getElementById("tb1").style.display = "none"; document.getElementById("tb2").style.display = "none"; document.getElementById("tb3").style.display = "none";} else { document.getElementById("format1").innerHTML = "Paragraph"; document.getElementById("fontface1").innerHTML = "Verdana"; document.getElementById("fontsize1").innerHTML = "2"; var kids = document.getElementsByTagName('DIV'); for (var i=0; i < kids.length; i++) { switch(kids[i].className)
{ case "rtebtn1":
if (kids[i].onmouseover != rteBtnMouseOver)
{ kids[i].onmouseover = rteBtnMouseOver;}
if (kids[i].onclick != rteAction)
{ kids[i].onclick = rteAction;}
if (kids[i].className == "rtebtn4") { if (kids[i].onmouseout != rteBtnMouseDown)
{ kids[i].onmouseout = rteBtnMouseDown;}
} else { if (kids[i].onmouseout != rteBtnMouseOut)
{ kids[i].onmouseout = rteBtnMouseOut;}
}
if (kids[i].onmousedown != rteBtnMouseDown)
{ kids[i].onmousedown = rteBtnMouseDown;}
if (kids[i].onmouseup != rteBtnMouseUp)
{ kids[i].onmouseup = rteBtnMouseUp;}
break; case "rtebtn2":
kids[i].className = "rtebtn1"; if (kids[i].onmouseover != rteBtnMouseOver)
{ kids[i].onmouseover = rteBtnMouseOver;}
if (kids[i].onclick != rteAction)
{ kids[i].onclick = rteAction;}
if (kids[i].className == "rtebtn4") { if (kids[i].onmouseout = rteBtnMouseDown)
{ kids[i].onmouseout = rteBtnMouseDown;}
} else { if (kids[i].onmouseout != rteBtnMouseOut)
{ kids[i].onmouseout = rteBtnMouseOut;}
}
if (kids[i].onmousedown != rteBtnMouseDown)
{ kids[i].onmousedown = rteBtnMouseDown;}
if (kids[i].onmouseup != rteBtnMouseUp)
{ kids[i].onmouseup = rteBtnMouseUp;}
break; case "rtebtn3":
kids[i].className = "rtebtn1"; if (kids[i].onmouseover != rteBtnMouseOver)
{ kids[i].onmouseover = rteBtnMouseOver;}
if (kids[i].onclick != rteAction)
{ kids[i].onclick = rteAction;}
if (kids[i].className == "rtebtn4") { if (kids[i].onmouseout != rteBtnMouseDown)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -