📄 html_editor.js
字号:
addText="<DIV align=\"left\">"+txt+"</DIV>"; } } } if(Action==13) { if (selectedText != "") { document.mainForm.Text1.value = document.mainForm.Text1.value.replace(selectedTextFlag, "<DIV align=\"center\">" + selectedText + "</DIV>"); } else if (caretPos && caretPos.text != document.mainForm.Text1.value) { txt=prompt("Text to align center","Text"); if(txt!=null) { caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? "<DIV align=\"center\">" + txt + "</DIV> " : "<DIV align=\"center\">" + txt + "</DIV>"; } } else { txt=prompt("Text to align center","Text"); if(txt!=null) { addText="<DIV align=\"center\">"+txt+"</DIV>"; } } } if(Action==14) { if (selectedText != "") { document.mainForm.Text1.value = document.mainForm.Text1.value.replace(selectedTextFlag, "<DIV align=\"right\">" + selectedText + "</DIV>"); } else if (caretPos && caretPos.text != document.mainForm.Text1.value) { txt=prompt("Text to align right","Text"); if(txt!=null) { caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? "<DIV align=\"right\">" + txt + "</DIV> " : "<DIV align=\"right\">" + txt + "</DIV>"; } } else { txt=prompt("Text to align right","Text"); if(txt!=null) { addText="<DIV align=\"right\">"+txt+"</DIV>"; } } } if(Action==17) { if (selectedText != "") { document.mainForm.Text1.value = document.mainForm.Text1.value.replace(selectedTextFlag, "<P align=\"justify\">" + selectedText + "</P>"); } else if (caretPos && caretPos.text != document.mainForm.Text1.value) { txt=prompt("Text to align justify","Text"); if(txt!=null) { caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? "<P align=\"justify\">" + txt + "</P> " : "<P align=\"justify\">" + txt + "</P>"; } } else { txt=prompt("Text to align justify","Text"); if(txt!=null) { addText="<P align=\"justify\">"+txt+"</P>"; } } } if (addText != null && addText != "") { displayHTML(document.mainForm.Text1.value + addText); document.mainForm.Text1.value+=addText; } else { displayHTML(document.mainForm.Text1.value); } if (document.all && selectedText != "") { temp = document.mainForm.Text1.value; document.mainForm.Text1.value = ""; document.mainForm.Text1.select(); document.mainForm.Text1.blur(); document.mainForm.Text1.value = temp; selectedText = ""; } document.mainForm.Text1.focus();}function addTable(imageName) { restoreImages(imageName); Undo = document.mainForm.Text1.value; if (document.mainForm.Text1.createTextRange && document.mainForm.Text1.caretPos) { var caretPos = document.mainForm.Text1.caretPos; } var x = prompt("How many rows?", ""); if (x == null || x == "" || x < 0) x = 0; var y = (x != 0) ? prompt("How many columns?", "") : 0; if (y == null || y == "" || y < 0) y = 0; if ((x * y) != 0) { var tmptag = (confirm("Do you want a table border?")) ? " border=\"1\"" : " border=\"0\""; var addText = "\n<TABLE" + tmptag + ">"; for (var i=0; i<x; i++) { addText += "\n<TR>\n"; for (var j=0; j < y; j++) { addText += " <TD>" + (i*y + j + 1) + "</TD>\n"; } addText += "</TR>"; } addText += "\n</TABLE>\n"; if (caretPos && caretPos.text != document.mainForm.Text1.value) { caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? addText + " " : addText; } else { document.mainForm.Text1.value += addText; } displayHTML(document.mainForm.Text1.value); } document.mainForm.Text1.focus(); selectedText = "";}// Define more general HTML tagsfunction htmlTag (insertmode, inserttext, tagstart, tagmiddle, tagend) { this.insertmode = insertmode; this.inserttext = inserttext; this.tagstart = tagstart; this.tagmiddle = tagmiddle; this.tagend = tagend;}OL = new htmlTag ( 3, "Enter the first list item", "\n<OL>\n <LI>", "\n <LI>", "\n</OL>\n" );OL.inserttext2 = "Enter next list item:"UL = new htmlTag ( 3, "Enter the first list item", "\n<UL>\n <LI>", "\n <LI>", "\n</UL>\n" );UL.inserttext2 = "Enter next list item:"// Start tag and check for user input by calling htmlPromptfunction addHTML (selection, imageName) { restoreImages(imageName); Undo = document.mainForm.Text1.value; if (document.mainForm.Text1.createTextRange && document.mainForm.Text1.caretPos) { var caretPos = document.mainForm.Text1.caretPos; } var addText = selection.tagstart; var tmp = htmlPrompt (selection); if (tmp != null) { addText += tmp + selection.tagend; if (caretPos && caretPos.text != document.mainForm.Text1.value) { caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? addText + " " : addText; } else { document.mainForm.Text1.value += addText; } displayHTML(document.mainForm.Text1.value); } document.mainForm.Text1.focus(); selectedText = "";}// Prompt for user input and return string or nullfunction htmlPrompt (selection) { if (selection.insertmode == 2) return prompt(selection.inserttext, ""); if (selection.insertmode == 3) { var i = prompt (selection.inserttext, ""); if ((i != null) && (i != "")) { var addText = i + "</LI>"; i = prompt(selection.inserttext2, ""); while ((i != null) && (i != "")) { addText += selection.tagmiddle + i + "</LI>"; i = prompt(selection.inserttext2, ""); } } return addText; } if (selection.insertmode == 4) { var count = 0; var addText = ""; var i = prompt(selection.inserttext, ""); var j = prompt(selection.inserttext2, ""); while ((i != null) && (i != "") && (j != null) && (j != "")) { if (++count > 1) addText += selection.tagmiddle2; addText += i + selection.tagmiddle + j; i = prompt(selection.inserttext, ""); j = prompt(selection.inserttext2, ""); } return addText; } if (selection.insertmode == 5) { var i = prompt(selection.inserttext, "http://"); if (i != null) { if (i == "") i = selection.text; var j = prompt(selection.inserttext2, "click here"); if (j != null) return (i + selection.tagmiddle + j); } } return null;}function resetPage(imageName) { restoreImages(imageName); if(confirm("Reset the page?")) { document.mainForm.Text1.value=""; displayHTML(""); } document.mainForm.Text1.focus();}function displayHTML(txt) { ViewHTML.setHTML(txt); setHiddenValue(txt);}function undo(imageName) { restoreImages(imageName); Redo = document.mainForm.Text1.value document.mainForm.Text1.value = Undo; Undo = Redo; displayHTML(document.mainForm.Text1.value); document.mainForm.Text1.focus();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -