📄 editor.js
字号:
strHTML = "<" + el.options[el.selectedIndex].value + ">" + theiframe.document.selection.createRange().text + "</" + el.options[el.selectedIndex].value + ">";
theiframe.document.selection.createRange().pasteHTML(strHTML);
theiframe.focus();
//theiframe.document.selection.createRange().select();
if (el.options[el.selectedIndex].value=="DEL"){
if (iframeobj["SUP"])iframeobj["SUP"].removeNode();
if (iframeobj["SUB"])iframeobj["SUB"].removeNode();
}
else if (el.options[el.selectedIndex].value=="SUB")if (iframeobj["SUP"])iframeobj["SUP"].removeNode();
else if (el.options[el.selectedIndex].value=="SUP")if (iframeobj["SUB"])iframeobj["SUB"].removeNode();
else if (el.options[el.selectedIndex].value=="BIG")if (iframeobj["SMALL"])iframeobj["SMALL"].removeNode();
else if (el.options[el.selectedIndex].value=="SMALL")if (iframeobj["BIG"])iframeobj["BIG"].removeNode();
}
}
function help(){
window.open("htmlfaq.net.htm","","");
}
function findiframeobj(){
srcE=(!arguments[0])?temp_upobj:arguments[0];
if (!arguments[1])iframeobj=new Array();
if (srcE.tagName){
iframeobj[srcE.tagName]=srcE;
var y=0;
for (x=0;x<selectedobj.length;x++){
if (srcE.tagName==selectedobj[x]){
y=1;
break;
}
}
if (y==0&&srcE.parentElement!=null)findiframeobj(srcE.parentElement,true)
}
}
function toselected(obj,what){
for (i=0;iobj.options.length;i++){
var noselect=0;
if (obj.options[i].value==what){
obj.options[i].selected=true;
noselect=1;
}
//if (noselect==0)obj.options[0].selected=true;
}
}
//*************************************************************************************
function ContextMenu(){//让表格属性是否可用
if (isHTMLMode)return;
temp_upobj=window.theiframe.event.srcElement;
findiframeobj();
var alltag=new Array("STRONG","EM","U","P","DIV","OL","UL","TD","TABLE","IMG","HR","BLOCKQUOTE","FONT","SPAN","A","SUP","SUB","DEL","BLINK","BIG","SMALL","PRE","H1","H2","H3","H4");
var no_tag=new Array();
//alert(iframeobj[0]);
for (x=0;x<alltag.length;x++){
if (!iframeobj[alltag[x]])no_tag[alltag[x]]=1;
}
if (no_tag["STRONG"]&&window.document.all.sty_bold.className=='btnmouseup')window.document.all.sty_bold.className='btnmouseout';
if (no_tag["EM"]&&window.document.all.sty_italic.className=='btnmouseup')window.document.all.sty_italic.className='btnmouseout';
if (no_tag["U"]&&window.document.all.sty_underline.className=='btnmouseup')window.document.all.sty_underline.className='btnmouseout';
if (no_tag["A"]){
window.document.all.sty_link[0].value='';
window.document.all.sty_target[0].selectedIndex='0';
window.document.all.sty_target[0].disabled=true;
window.document.all.sty_link[1].value='';
window.document.all.sty_target[1].selectedIndex='0';
window.document.all.sty_target[1].disabled=true;
}
if (no_tag["P"]&&no_tag["DIV"]){
if (window.document.all.sty_aleft.className=='btnmouseup')window.document.all.sty_aleft.className='btnmouseout';
if (window.document.all.sty_center.className=='btnmouseup')window.document.all.sty_center.className='btnmouseout';
if (window.document.all.sty_aright.className=='btnmouseup')window.document.all.sty_aright.className='btnmouseout';
}
if (no_tag["IMG"])document.all.ImgPro.style.display = "none";
if (no_tag["TD"])document.all.TDPro.style.display = "none";
if (no_tag["TABLE"])document.all.TabPro.style.display = "none";
if (no_tag["OL"]&&window.document.all.sty_numlist.className=='btnmouseup')window.document.all.sty_numlist.className='btnmouseout';
if (no_tag["UL"]&&window.document.all.sty_bullist.className=='btnmouseup')window.document.all.sty_bullist.className='btnmouseout';
if (no_tag["PRE"]&&no_tag["H1"]&&no_tag["H2"]&&no_tag["H3"]&&no_tag["H4"])window.document.all.sty_block.options[0].selected=true;
if (no_tag["DEL"]&&no_tag["SUB"]&&no_tag["SUP"]&&no_tag["BIG"]&&no_tag["SMALL"]&&no_tag["BLINK"])window.document.all.special_type.options[0].selected=true;
if (no_tag["FONT"]){
window.document.all.sty_fontname.options[0].selected=true;
window.document.all.sty_fontsize.options[0].selected=true;
document.all.sty_fontcolor.style.backgroundColor="";
document.all.sty_fontcolor_input.value="";
}
document.all.formatPro.style.display = "";
if (iframeobj["STRONG"])window.document.all.sty_bold.className='btnmouseup';
if (iframeobj["EM"])window.document.all.sty_italic.className='btnmouseup';
if (iframeobj["U"])window.document.all.sty_underline.className='btnmouseup';
if (iframeobj["A"]){
window.document.all.sty_link[0].value=iframeobj["A"].href;
window.document.all.sty_target[0].disabled=false;
window.document.all.sty_link[1].value=iframeobj["A"].href;
window.document.all.sty_target[1].disabled=false;
if (iframeobj["A"].target){
window.document.all.sty_target[0].value=iframeobj["A"].target;
window.document.all.sty_target[1].value=iframeobj["A"].target;
}
else {
window.document.all.sty_target[0].selectedIndex='0';
window.document.all.sty_target[1].selectedIndex='0';
}
}
if (iframeobj["TABLE"]){
document.all.formatPro.style.display = "none";
document.all.TabPro.style.display = "";
document.all.TabBG.value=iframeobj["TABLE"].style.backgroundColor;
document.all.buttonTabBG.style.background=document.all.TabBG.value;
document.all.TabW.value=iframeobj["TABLE"].width;
document.all.TabH.value=iframeobj["TABLE"].height;
document.all.TabCellpadding.value=iframeobj["TABLE"].cellPadding;
document.all.TabCellspacing.value=iframeobj["TABLE"].cellSpacing;
document.all.TabBorder.value=iframeobj["TABLE"].border;
toselected(document.all.TabAlign,iframeobj['TABLE'].align.toLowerCase());
}
if (iframeobj["TD"]){
if (!iframeobj["IMG"]){
document.all.TDPro.style.display = "";
document.all.ansyncTD.onclick=ansyncTD;
document.all.deleteRow.onclick=deleteRow;
document.all.insertRow.onclick=insertRow;
document.all.deleteCell.onclick=deleteCell;
document.all.insertCell.onclick=insertCell;
document.all.TDW.value=iframeobj["TD"].width;
document.all.TDH.value=iframeobj["TD"].height;
document.all.TDBG.value=iframeobj["TD"].style.backgroundColor;
document.all.buttonTDBG.style.backgroundColor=iframeobj["TD"].style.backgroundColor;
toselected(document.all.TDAlign,iframeobj['TD'].align.toLowerCase());
toselected(document.all.TDVAlign,iframeobj['TD'].vAlign.toLowerCase());
}
}
if (iframeobj['IMG']){
document.all.formatPro.style.display='none';
document.all.TDPro.style.display='none';
document.all.ImgPro.style.display='';
document.all.imgid.value=iframeobj['IMG'].name;
document.all.imgid.value=iframeobj['IMG'].id
document.all.imgborder.value=iframeobj['IMG'].border;
document.all.imgh.value=iframeobj['IMG'].height;
document.all.imgw.value=iframeobj['IMG'].width;
document.all.imgsrc.value=iframeobj['IMG'].src;
document.all.imgalt.value=iframeobj['IMG'].alt;
toselected(document.all.imgalign,iframeobj['IMG'].align.toLowerCase());
}
if (iframeobj['HR'])document.all.formatPro.style.display='none';
if (iframeobj["OL"])window.document.all.sty_numlist.className='btnmouseup';
if (iframeobj["UL"])window.document.all.sty_bullist.className='btnmouseup';
if (iframeobj["P"]){
obj=iframeobj["P"];
if (obj.align=="left")window.document.all.sty_aleft.className='btnmouseup';
else if (obj.align=="center")window.document.all.sty_center.className='btnmouseup';
else if (obj.align=="right")window.document.all.sty_aright.className='btnmouseup';
}
if (iframeobj["DIV"]){
obj=iframeobj["DIV"];
if (obj.align=="left")window.document.all.sty_aleft.className='btnmouseup';
else if (obj.align=="center")window.document.all.sty_center.className='btnmouseup';
else if (obj.align=="right")window.document.all.sty_aright.className='btnmouseup';
}
if (iframeobj["PRE"])window.document.all.sty_block.options[1].selected=true;
else if (iframeobj["H1"])window.document.all.sty_block.options[2].selected=true;
else if (iframeobj["H2"])window.document.all.sty_block.options[3].selected=true;
else if (iframeobj["H3"])window.document.all.sty_block.options[4].selected=true;
else if (iframeobj["H4"])window.document.all.sty_block.options[5].selected=true;
if (iframeobj["SUP"])window.document.all.special_type.options[1].selected=true;
else if (iframeobj["SUB"])window.document.all.special_type.options[2].selected=true;
else if (iframeobj["DEL"])window.document.all.special_type.options[3].selected=true;
else if (iframeobj["BLINK"])window.document.all.special_type.options[4].selected=true;
else if (iframeobj["BIG"])window.document.all.special_type.options[5].selected=true;
else if (iframeobj["SMALL"])window.document.all.special_type.options[6].selected=true;
if (iframeobj["FONT"]){
if (iframeobj["FONT"].face!="")toselected(document.all.sty_fontname,iframeobj["FONT"].face);
if (iframeobj["FONT"].size!="")toselected(document.all.sty_fontsize,iframeobj["FONT"].size);
if (iframeobj["FONT"].color!=""){
document.all.sty_fontcolor.style.backgroundColor=iframeobj["FONT"].color;
document.all.sty_fontcolor_input.value=iframeobj["FONT"].color;
}
}
}
//***********************************************************************************
function WinBtnStyle(){
if (isHTMLMode)return;
totalnum=winbtn.length;
for (i=0;i<totalnum;i++){
obj=eval("document.all."+winbtn[i]);
obj.className="btnmouseout";
obj.onmouseover=WinBtn_mouseover;
obj.onmousedown=WinBtn_mousedown;
obj.onclick=mClk;
obj.onmouseout=WinBtn_mouseout;
}
}
function find_style_obj(obj){
if (obj.tagName=="TD")return obj;
else return obj.parentElement;
}
function mClk() {//点击空白区域等于点击图片
if(event.srcElement.tagName!='IMG')obj=event.srcElement.children.tags('IMG')[0];
else obj=event.srcElement;
obj.click();
obj.onkeyup=WinBtn_click;
obj.onkeyup();
}
function WinBtn_mousedown(){
obj=find_style_obj(event.srcElement);
temp_winbtn[obj.id]=obj.className;
obj.className="btnmousedown";
}
function WinBtn_mouseover(){
obj=find_style_obj(event.srcElement);
if (obj.className!="btnmouseup")obj.className="btnmouseover";
}
function WinBtn_mouseout(){
obj=find_style_obj(event.srcElement);
if (obj.className!="btnmouseup")obj.className="btnmouseout";
}
function remove_POrDiv(obj_theiframe){
//findiframeobj();
if (iframeobj["P"])iframeobj["P"].removeNode();
else if (iframeobj["DIV"])iframeobj["DIV"].removeNode();
}
function WinBtn_click(){
obj=find_style_obj(event.srcElement);
if (obj.id=='sty_table'||obj.id=='sty_wlink'||obj.id=='sty_image'||obj.id=='sty_Anchor'){
obj.className="btnmouseout";
}
else if (obj.id=="sty_bold"||obj.id=="sty_italic"||obj.id=="sty_underline"){
if (theiframe.document.selection.createRange().text!=""&&temp_winbtn[obj.id]!="btnmouseup")obj.className="btnmouseup";
}
else if (obj.id=="sty_numlist"){
findiframeobj(theiframe.document.selection.createRange().parentElement())
if (iframeobj["OL"]){
obj.className="btnmouseup";
document.all.sty_bullist.className="btnmouseout";
}
//else remove_POrDiv(theiframe.document.selection.createRange().parentElement());
}
else if (obj.id=="sty_bullist"){
findiframeobj(theiframe.document.selection.createRange().parentElement())
if (iframeobj["UL"]){
obj.className="btnmouseup";
document.all.sty_numlist.className="btnmouseout";
}
//else remove_POrDiv(theiframe.document.selection.createRange().parentElement());
}
else if (obj.id=="sty_aleft"||obj.id=="sty_center"||obj.id=="sty_aright"){
findiframeobj(theiframe.document.selection.createRange().parentElement())
if (temp_winbtn[obj.id]=="btnmouseup"){
obj.className="btnmouseout";
remove_POrDiv(theiframe.document.selection.createRange().parentElement());
}
else {
obj.className="btnmouseup";
if (obj.id=="sty_aleft"){
document.all.sty_center.className="btnmouseout";
document.all.sty_aright.className="btnmouseout";
}
else if (obj.id=="sty_center"){
document.all.sty_aleft.className="btnmouseout";
document.all.sty_aright.className="btnmouseout";
}
else if (obj.id=="sty_aright"){
document.all.sty_aleft.className="btnmouseout";
document.all.sty_center.className="btnmouseout";
}
}
}
else if (obj.id=="sty_outdent"){
findiframeobj(theiframe.document.selection.createRange().parentElement())
if (document.all.sty_numlist.className=="btnmouseup"){
if (!iframeobj["OL"])document.all.sty_numlist.className="btnmouseout";
if (!iframeobj["UL"])document.all.sty_bullist.className="btnmouseout";
remove_POrDiv(theiframe.document.selection.createRange().parentElement());
}
else if (document.all.sty_bullist.className=="btnmouseup"){
if (!iframeobj["OL"])document.all.sty_numlist.className="btnmouseout";
if (!iframeobj["UL"])document.all.sty_bullist.className="btnmouseout";
remove_POrDiv(theiframe.document.selection.createRange().parentElement())
}
}
else obj.className="btnmouseover";
}
function InitDocument(){
theiframe.document.designMode="On"
var oldContent=(document.all.oldContent.innerHTML!="")?document.all.oldContent.innerHTML:document.all.Content.innerHTML;
theiframe.document.open();
theiframe.document.write(oldContent);
theiframe.document.close();
document.all.htmlMode.checked=false;
window.theiframe.document.attachEvent("onmouseup",ContextMenu);
window.theiframe.document.attachEvent("onkeyup",ContextMenu);
WinBtnStyle();
}
window.onload=InitDocument;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -