📄 editjs.js
字号:
var alloweditsource = new Array();
var tabview = new Array();
var ae_fieldname = new Array();
var ae_imagedata = new Array();
var ae_imageurl = new Array();
var ae_defaultfont = new Array();
var ae_baseurl = new Array();
var ae_breakonenter = new Array();
var inc = '';
ae_breakonenter[1] = true;
ae_baseurl[1] = document.location;
ae_defaultfont[1] = "";
tabview[1] = false;
alloweditsource[1] = true;
ae_imagedata[1] = '';
//ae_imageurl[1] = '/media';
ae_imageurl[1] = '../piclibrary';
DECMD_BOLD = 5000;
DECMD_COPY = 5002;
DECMD_CUT = 5003;
DECMD_DELETE = 5004;
DECMD_DELETECELLS = 5005;
DECMD_DELETECOLS = 5006;
DECMD_DELETEROWS = 5007;
DECMD_FINDTEXT = 5008;
DECMD_FONT = 5009;
DECMD_GETBACKCOLOR = 5010;
DECMD_GETBLOCKFMT = 5011;
DECMD_GETBLOCKFMTNAMES = 5012;
DECMD_GETFONTNAME = 5013;
DECMD_GETFONTSIZE = 5014;
DECMD_GETFORECOLOR = 5015;
DECMD_HYPERLINK = 5016;
DECMD_IMAGE = 5017;
DECMD_INDENT = 5018;
DECMD_INSERTCELL = 5019;
DECMD_INSERTCOL = 5020;
DECMD_INSERTROW = 5021;
DECMD_INSERTTABLE = 5022;
DECMD_ITALIC = 5023;
DECMD_JUSTIFYCENTER = 5024;
DECMD_JUSTIFYLEFT = 5025;
DECMD_JUSTIFYRIGHT = 5026;
DECMD_LOCK_ELEMENT = 5027;
DECMD_MAKE_ABSOLUTE = 5028;
DECMD_MERGECELLS = 5029;
DECMD_ORDERLIST = 5030;
DECMD_OUTDENT = 5031;
DECMD_PASTE = 5032;
DECMD_REDO = 5033;
DECMD_REMOVEFORMAT = 5034;
DECMD_SELECTALL = 5035;
DECMD_SEND_BACKWARD = 5036;
DECMD_BRING_FORWARD = 5037;
DECMD_SEND_BELOW_TEXT = 5038;
DECMD_BRING_ABOVE_TEXT = 5039;
DECMD_SEND_TO_BACK = 5040;
DECMD_BRING_TO_FRONT = 5041;
DECMD_SETBACKCOLOR = 5042;
DECMD_SETBLOCKFMT = 5043;
DECMD_SETFONTNAME = 5044;
DECMD_SETFONTSIZE = 5045;
DECMD_SETFORECOLOR = 5046;
DECMD_SPLITCELL = 5047;
DECMD_UNDERLINE = 5048;
DECMD_UNDO = 5049;
DECMD_UNLINK = 5050;
DECMD_UNORDERLIST = 5051;
DECMD_PROPERTIES = 5052;
DECMD_VIEWSOURCE = 6000;
DECMD_EDITSOURCE = 6001;
DECMD_ABOUT = 6002;
DECMD_TOGGLE_DETAILS = 6004;
DECMD_SAVE = 6005;
DECMD_EDITTABLE = 6006;
DECMD_SPELLCHECK = 6007;
DECMD_SPECIAL_CHARS = 6008;
DECMD_IMAGE_PROPERTIES = 6009;
DECMD_HR = 6010;
OLECMDEXECOPT_DODEFAULT = 0;
OLECMDEXECOPT_PROMPTUSER = 1;
OLECMDEXECOPT_DONTPROMPTUSER = 2;
DECMDF_NOTSUPPORTED = 0;
DECMDF_DISABLED = 1;
DECMDF_ENABLED = 3;
DECMDF_LATCHED = 7;
DECMDF_NINCHED = 11;
DEAPPEARANCE_FLAT = 0;
DEAPPEARANCE_3D = 1;
OLE_TRISTATE_UNCHECKED = 0;
OLE_TRISTATE_CHECKED = 1;
OLE_TRISTATE_GRAY = 2;
function ae_onerror(msg, detail, popup) {
errwin = this;
if(popup) errwin = window.open("","","scrollbars=yes,width=500,height=400,resizable=yes", true);
errwin.document.write("<HR>对不起,操作出错。</H4><P>");
errwin.document.write(msg);
errwin.document.write(detail);
errwin.document.write("<P><P></TD></TR></TABLE><P><HR>");
}
var ae_olddocmd;
aeObjects = new Array();
var aeFieldnames = new Array();
var DHTMLSafe;
var ae_count;
var ae_hot;
var ae_sourceview=false;
var ae_oldfontfamily='';
var ae_oldfontsize='';
var ae_HTMLMode = new Array();
var tableparamobj=new ActiveXObject("DEInsertTableParam.DEInsertTableParam");
tableparamobj.NumRows=3;
tableparamobj.NumCols=3;
tableparamobj.Caption="";
tableparamobj.TableAttrs="border=0 cellpadding=0 cellspacing=0 width=75%";
tableparamobj.CellAttrs="";
var is_ie4 = ((parseInt(navigator.appVersion) == 4) && (navigator.userAgent.toLowerCase().indexOf("msie 5")==-1) && (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1) );
function ae_previewNewWin(p) {
prevWin = window.open("", "", "left=40,top=10,width=720,height=540,menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes");
if (ae_HTMLMode[1] == true){
prevWin.document.write("<body size=2>" + DHTMLSafe.DOM.body.innerText);
}else{
prevWin.document.write("<body size=2>" + DHTMLSafe.DOM.body.innerHTML);
}
if (p==0){
prevWin.document.title = "内容预览";
}else{
prevWin.document.write ("\n<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0></OBJECT>\n<script language=\"JavaScript\">WB.ExecWB(7,1);\<\/script>");
prevWin.document.close;
}
}
function ae_initialize(num) {
ae_count=num;
thisContentItem=eval("document.all.TempContent");
thisForm=thisContentItem;
while(thisForm.tagName!="FORM"&&thisForm.tagName!="HTML") {
thisForm=thisForm.parentElement;
}
if(thisForm.tagName!="HTML") {
DHTMLSafe = eval("thisForm.DHTMLSafe"+num);
aeObjects[num] = DHTMLSafe;
aeObjects[thisContentItem.name] = DHTMLSafe;
aeFieldnames[num] = thisContentItem.name;
thisForm.onsubmit = ae_onSubmit;
}
else {
alert("对不起,操作出错。", "", true);
return;
}
DHTMLSafe.NewDocument();
DHTMLSafe.BaseURL=ae_baseurl[num];
set_tbstates(num);
ae_onLoad(num);
ae_HTMLMode[num] = false;
}
function ae_onLoad(num) {
DHTMLSafe=aeObjects[num];
if(DHTMLSafe.Busy) {
setTimeout("ae_onLoad("+num+");", 100);
return;
}
if(num==1) window.onunload = ae_onUnload;
if(ae_defaultfont[num].length)
DHTMLSafe.DOM.body.style.font=ae_defaultfont[num];
else {
DHTMLSafe.DOM.body.style.fontFamily="宋体";
DHTMLSafe.DOM.body.style.fontSize="12px";
}
if(oSel=eval('document.all.oQuickFormat'+num)) { //Populate QuickFormat Box
var f=new ActiveXObject("DEGetBlockFmtNamesParam.DEGetBlockFmtNamesParam");
DHTMLSafe.ExecCommand(DECMD_GETBLOCKFMTNAMES,OLECMDEXECOPT_DODEFAULT,f);
vbarr = new VBArray(f.Names);
arr = vbarr.toArray();
for (var i=0;i<arr.length;i++) {
oOption = document.createElement("OPTION");
oSel.options.add(oOption);
oOption.text=arr[i];
oOption.name=arr[i];
}
}
thisContentItem=eval("document.all.TempContent");
if(thisContentItem.value.length)
aeObjects[num].DOM.body.innerHTML = thisContentItem.value;
else
aeObjects[num].DOM.body.innerHTML = " ";
set_tbstates(num);
if(typeof(aeapi_local_onLoad)=='function')
aeapi_local_onLoad(DHTMLSafe, aeFieldnames[num]);
if (typeof(aeapi_onLoad)=='function')
aeapi_onLoad(DHTMLSafe, aeFieldnames[num]);
}
function ae_onUnload() {
var ae_content = "";
var i;
for(i=1;i<=ae_count;i++) {
DHTMLSafe=aeObjects[i];
thisContentItem = eval("document.all.TempContent");
if(ae_sourceview) ae_editsourceinline(i,false);
var content = DHTMLSafe.DOM.body.innerHTML;
thisContentItem.value = content;
}
}
function ae_onSubmit() {
var ae_content = "";
var i;
for(i=1;i<=ae_count;i++) {
DHTMLSafe=aeObjects[i];
if(ae_sourceview) ae_editsourceinline(i,false);
thisContentItem = eval("document.all.TempContent");
if(typeof(aeapi_local_onBeforeSave)=='function')
ae_content = aeapi_local_onBeforeSave(DHTMLSafe, aeFieldnames[i]);
else if (typeof(aeapi_onBeforeSave)=='function')
ae_content = aeapi_onBeforeSave(DHTMLSafe, aeFieldnames[i]);
else
ae_content = ae_onBeforeSave(DHTMLSafe, aeFieldnames[i]);
thisContentItem.value = ae_content;
}
}
function ae_onkeypress(num) {
var sel;
DHTMLSafe=aeObjects[num];
if(ae_breakonenter[num]||ae_sourceview) {
switch(DHTMLSafe.DOM.parentWindow.event.keyCode) {
case 10:
DHTMLSafe.DOM.parentWindow.event.keyCode = 13;
break;
case 13:
if(DHTMLSafe.QueryStatus(DECMD_UNORDERLIST)!=DECMDF_LATCHED) {
DHTMLSafe.DOM.parentWindow.event.returnValue = false;
sel = DHTMLSafe.DOM.selection.createRange();
sel.pasteHTML("<BR>");
sel.collapse(false);
sel.select();
}
break;
default:
break;
}
}
}
function ae_clear(){
if (confirm("您真的要清除所写的内容吗?")){
DHTMLSafe.DOM.body.innerHTML="";
}
DHTMLSafe.focus();
DHTMLSafe.DOM.body.focus();
}
function ae_onmousedown(num) {
if(typeof(document.all.frame1) != "undefined") {
if(document.all.frame1.style.visibility == "visible") {
cancelTable(false);
return;
}
}
}
function ae_onclick(num) {
set_tbstates(num);
}
function ae_ondisplaychange(num) {
if(DHTMLSafe.Busy) return;
set_tbstates(num);
}
function ae_onmenuaction(itemIndex, num) {
ae_onCommand(ContextMenu[itemIndex].cmdId, num);
}
function ae_Clear(cmdId, num) {
}
//未完成1.加删除线;2.自定义修改意见;3.加批注
function ae_insertPage(){
DHTMLSafe.DOM.selection.createRange().pasteHTML("<br>[---P---]<br>");
DHTMLSafe.focus();
DHTMLSafe.DOM.body.focus();
}
function insertDelMark(){
DHTMLSafe.document.execCommand('ForeColor', "", "#FF0000");
DHTMLSafe.document.execCommand('StrikeThrough', "", "");
}
function insertErrorMe() {
content =prompt("请写入错误内容:","");
if(content!=null) {
var m_objHTML = DHTMLSafe.DOM.document.selection.createRange();
DHTMLSafe.document.execCommand('underline');
originHTML = m_objHTML.htmlText;
targetHTML = "<span id style=color:red>"+originHTML+"</span>"+"<img style=\"cursor:hand;\" src=EditorImg/face0.gif alt='"+content+"'>";
m_objHTML.pasteHTML(targetHTML);
DHTMLSafe.document.execCommand('underline');
}
}
function insertPostil(){
if (!validateMode()) return;
content = prompt("请加批注:","");
if(content!=null){
content = "<font color='red'>【" + content + "】</font>";
DHTMLSafe.DOM.document.selection.createRange().pasteHTML(content);
}
pureText = false;
DHTMLSafe.focus();
}
//至此
function ae_onCommand(cmdId, num) {
if (ae_HTMLMode[num]) { alert("请先切换到可视编辑模式。");return; }
if(typeof(num)=="undefined") {
num=ae_hot;
}
DHTMLSafe=aeObjects[num];
if(cmdId==null) cmdid=eval(window.event.srcElement.cid);
else cmdid=cmdId;
doFocus=true;
switch(parseInt(cmdid)) {
case DECMD_IMAGE:
oSel = DHTMLSafe.DOM.selection;
if (oSel.type == "Control") {
ae_imageProperties(num);
}else {
DHTMLSafe.DOM.selection.createRange().collapse(false);
onImagewin(num);
}
doFocus=false;
break;
case DECMD_INSERTTABLE:
onTableWin(num);
doFocus=false;
break;
case DECMD_EDITSOURCE:
if(tabview[num]) ae_editsourceinline(num);
else {
ae_editsource(num);
doFocus=false;
}
break;
case DECMD_ABOUT:
ae_about();
doFocus=false;
break;
case DECMD_TOGGLE_DETAILS:
ae_onToggleDetails(null, num);
break;
//case DECMD_SAVE:
//if (confirm("你确定要保存内容吗?\t\n点击 [确定] 后保存并将关闭本窗口\t\n\n注意:\n如果你不想保留更改内容\n请点击 [取消] 后直接关闭窗口。\t")){
//document.form1.TempContent.value=DHTMLSafe.DOM.body.innerHTML;
//window.returnValue=DHTMLSafe.DOM.innerHTML;
//window.close();
//}
//editform.ae_tx_content1.value=DHTMLSafe.DOM.body.innerHTML;
//break;
case DECMD_EDITTABLE:
editTableWin(num);
doFocus=false;
break;
case DECMD_HYPERLINK:
ae_hyperlinkwin(num);
doFocus=false;
break;
case DECMD_SPELLCHECK:
ae_spellcheckwin(num);
doFocus=false;
break;
case DECMD_SPECIAL_CHARS:
ae_specialchars();
doFocus=false;
break;
//加
case DECMD_IMAGE_PROPERTIES:
oSel = DHTMLSafe.DOM.selection.createRange();
for (i=0; i<oSel.length; i++) {
if (oSel(i).tagName == "IMG") {
ae_imageProperties(num);
doFocus=false;
}
}
break;
case DECMD_PASTE:
ae_onPaste(num);
doFocus=false;
break;
case DECMD_HR:
oSel = DHTMLSafe.DOM.selection;
if (oSel.type == "Control") {
alert("您已选中水平线。\n如需插入新的水平线,请先取消选择。");
return;
}else{
ae_onHr(num);
doFocus=false;
}
break;
//至此
default:
if(DHTMLSafe.QueryStatus(cmdid)!=DECMDF_DISABLED) {
DHTMLSafe.ExecCommand(cmdid, OLECMDEXECOPT_DODEFAULT);
}
break;
}
if (doFocus) {
DHTMLSafe.focus();
DHTMLSafe.DOM.body.focus();
}
//原if (doFocus) DHTMLSafe.focus();
}
//加
function ae_onHr(num) {
DHTMLSafe=aeObjects[num];
DHTMLSafe.focus();
if (typeof(ae_hrwin) == "undefined" || ae_hrwin.closed) { //short circuit eval
var szURL=inc + "../editor/hr.htm?instance=" + num;
ae_hrwin = window.showModalDialog(szURL,window,"dialogHeight: 210px; dialogWidth: 355px; dialogTop: 150px; dialogLeft: 150px; center: Yes; help: No; resizable: No; status: No;");
}
}
function ae_imageProperties(num) {
DHTMLSafe=aeObjects[num];
DHTMLSafe.focus();
if (typeof(ae_imgpropwin) == "undefined" || ae_imgpropwin.closed) { //short circuit eval
var szURL=inc + "../editor/imageProperties.htm?instance=" + num;
ae_imgpropwin = window.showModalDialog(szURL,window,"dialogHeight: 300px; dialogWidth: 420px; dialogTop: 150px; dialogLeft: 150px; center: Yes; help: No; resizable: No; status: No;");
}
}
function replaceFontsWithSpans(aeObject, oElement, sNewClass) {
for(var i=0;i<oElement.childNodes.length;i++) {
replaceFontsWithSpans(aeObject, oElement.childNodes[i], sNewClass);
}
if(oElement.tagName=="FONT") {
if(oElement.face=="ae_newclass") {
sPreserve=oElement.innerHTML;
oNewNode=aeObject.DOM.createElement("SPAN");
oElement.replaceNode(oNewNode);
oNewNode.innerHTML=sPreserve;
oNewNode.className=sNewClass;
}
if(oElement.xclass!=null) {
sPreserve=oElement.innerHTML;
sClass=oElement.xclass;
oNewNode=aeObject.DOM.createElement("SPAN");
oElement.replaceNode(oNewNode);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -