📄 opencms_edithtml.js
字号:
TableContextMenu[3] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[4] = new ContextMenuItem(LANG_INSERTCOL, DECMD_INSERTCOL);
TableContextMenu[5] = new ContextMenuItem(LANG_DELETECOL, DECMD_DELETECOLS);
TableContextMenu[6] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[7] = new ContextMenuItem(LANG_INSERTCELL, DECMD_INSERTCELL);
TableContextMenu[8] = new ContextMenuItem(LANG_DELETECELL, DECMD_DELETECELLS);
TableContextMenu[9] = new ContextMenuItem(LANG_MERGECELL, DECMD_MERGECELLS);
TableContextMenu[10] = new ContextMenuItem(LANG_SPLITCELL, DECMD_SPLITCELL);
EDITOR.EDIT_HTML.focus();
}
// Submitts the Document to the OpenCms System
function doSubmit()
{
if(document.EDITOR.EDIT_HTML.DOM.documentElement) {
// IE5
document.EDITOR.content.value = escape(getChars(document.EDITOR.EDIT_HTML.filterSourceCode(document.EDITOR.EDIT_HTML.DOM.documentElement.outerHTML)));
} else {
// IE4
document.EDITOR.content.value = escape(document.EDITOR.EDIT_HTML.DocumentHTML);
}
}
// Main Function to access HTML-Editor functions.
function DECMD_UNDO_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_UNDO,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_REDO_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_REDO,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_FINDTEXT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_FINDTEXT,OLECMDEXECOPT_PROMPTUSER);
EDITOR.EDIT_HTML.focus();
}
function DECMD_CUT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_CUT,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_COPY_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_COPY,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_PASTE_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_PASTE,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function MENU_FILE_IMPORT_onclick()
{
docComplete = false;
EDITOR.EDIT_HTML.LoadDocument("", true);
EDITOR.EDIT_HTML.focus();
}
function MENU_FILE_EXPORT_onclick()
{
if (EDITOR.EDIT_HTML.CurrentDocumentPath != "") {
var path;
path = EDITOR.EDIT_HTML.CurrentDocumentPath;
if (path.substring(0, 7) == "http://")
EDITOR.EDIT_HTML.SaveDocument("", true);
else
EDITOR.EDIT_HTML.SaveDocument(EDITOR.EDIT_HTML.CurrentDocumentPath, false);
} else {
EDITOR.EDIT_HTML.SaveDocument("", true);
}
EDITOR.EDIT_HTML.focus();
}
function MENU_FILE_SAVEAS_onclick()
{
EDITOR.EDIT_HTML.SaveDocument("", true);
EDITOR.EDIT_HTML.focus();
}
//=======================================================
function ParagraphStyle_onchange()
{
document.EDITOR.EDIT_HTML.ExecCommand(DECMD_SETBLOCKFMT, OLECMDEXECOPT_DODEFAULT, EDITOR.BLOCK.value);
EDITOR.EDIT_HTML.focus();
}
function FontName_onchange()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_SETFONTNAME, OLECMDEXECOPT_DODEFAULT, EDITOR.FONTFACE.value);
EDITOR.EDIT_HTML.focus();
}
function FontSize_onchange()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_SETFONTSIZE, OLECMDEXECOPT_DODEFAULT, parseInt(EDITOR.FONTSIZE.value));
EDITOR.EDIT_HTML.focus();
}
function DECMD_BOLD_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_BOLD,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_ITALIC_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_ITALIC,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_UNDERLINE_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_UNDERLINE,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
//=======================================================
function DECMD_JUSTIFYLEFT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_JUSTIFYLEFT,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_JUSTIFYCENTER_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_JUSTIFYCENTER,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_JUSTIFYRIGHT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_JUSTIFYRIGHT,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_UNORDERLIST_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_UNORDERLIST,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_ORDERLIST_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_ORDERLIST,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_INDENT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_INDENT,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
function DECMD_OUTDENT_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_OUTDENT,OLECMDEXECOPT_DODEFAULT);
EDITOR.EDIT_HTML.focus();
}
<!-- Function to set the ForegroundColor with the data received set by the "selcolor" dialog -->
function setFGColor(arr)
{
if (arr != -1)
{
if (document.all.EDIT_HTML.QueryStatus( DECMD_GETFORECOLOR ) != DECMDF_DISABLED)
{
document.all.EDIT_HTML.ExecCommand(DECMD_SETFORECOLOR, OLECMDEXECOPT_DODEFAULT, arr);
}
window.clearInterval(CheckFGCol);
SelColor=-1;
}
}
<!-- Function to set the BackgroundColor with the data received set by the "selcolor" dialog -->
function setBGColor(arr)
{
if (arr != -1)
{
if (document.all.EDIT_HTML.QueryStatus( DECMD_SETBACKCOLOR ) != DECMDF_DISABLED )
{
document.all.EDIT_HTML.ExecCommand(DECMD_SETBACKCOLOR, OLECMDEXECOPT_DODEFAULT, arr);
}
window.clearInterval(CheckBGCol);
SelColor=-1;
}
}
function DECMD_SETFORECOLOR_onclick()
{
var arr = showModalDialog( "edit_html_selcolor.html",
"",
"font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:30em" );
if (arr != null)
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_SETFORECOLOR,OLECMDEXECOPT_DODEFAULT, arr);
}
}
function DECMD_SETBACKCOLOR_onclick()
{
var arr = showModalDialog( "../templates/selcolor.htm",
"",
"font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:30em" );
if (arr != null)
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_SETBACKCOLOR,OLECMDEXECOPT_DODEFAULT, arr);
}
EDITOR.EDIT_HTML.focus();
}
/* Checks if an table-element is selected in the DHTML Editor */
function checkTableSelection() {
var editor = document.all.EDIT_HTML;
var sel = editor.DOM.selection;
if(sel.type == "Control") {
var range = sel.createRange()(0);
// we have selected a table object
if(range.tagName == "TABLE" || range.tagName == "table") {
// get table properties
var args1 = new Array();
args1["border"] = range.border;
args1["cellpadding"] = range.cellPadding;
args1["cellspacing"] = range.cellSpacing;
if(range.bgColor != "" && range.bgColor.length > 0) {
args1["bgcolor"] = range.bgColor
}
//get new attributes
var args2 = new Array();
args2 = showModalDialog( "edit_html_changetable.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:25em");
// set the new attributes
if (args2 != null) {
for ( elem in args2 ) {
if ("border" == elem && args2["border"] != null) {
range.border = args2["border"];
}
else if ("cellpadding" == elem && args2["cellpadding"] != null) {
range.cellPadding = args2["cellpadding"];
}
else if ("cellspacing" == elem && args2["cellspacing"] != null) {
range.cellSpacing = args2["cellspacing"];
}
else if ("bgcolor" == elem && args2["bgcolor"] != null) {
range.bgColor = args2["bgcolor"];
}
}
}
}
}
else {
InsertTable();
}
}
/* Builds a new table */
function InsertTable()
{
var pVar = document.all.ObjTableInfo;
var args = new Array();
var arr = null;
document.all.ObjTableInfo.TableAttrs =" ";
document.all.ObjTableInfo.CellAttrs =" ";
<!-- Preset values for the Table Dialog. Data is stored in an array that is submitted to the dialog -->
args["NumRows"] = document.all.ObjTableInfo.NumRows;
args["NumCols"] = document.all.ObjTableInfo.NumCols;
args["TableAttrs"] =document.all.ObjTableInfo.TableAttrs;
args["CellAttrs"] = document.all.ObjTableInfo.CellAttrs;
args["Caption"] = document.all.ObjTableInfo.Caption;
args["BorderLineWidth"] = 1;
args["CellSpacing"] = 1;
args["CellPadding"] = 1;
args["TableAlignment"] = "left";
args["TableWidth"]=100;
args["TableHeight"]=100;
args["TableWidthMode"]="%";
args["TableHeightMode"]="%";
arr = null;
<!-- Call the "addtable" dialog and receive its results in the arr array -->
arr = showModalDialog( "edit_html_newtable.html",
args,
"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:40em");
if (arr != null)
{
<!-- Initialize table object. Values from the arr array are processed for creating the Control call -->
for ( elem in arr )
{
if ("NumRows" == elem && arr["NumRows"] != null)
{
document.all.ObjTableInfo.NumRows = arr["NumRows"];
}
else if ("NumCols" == elem && arr["NumCols"] != null)
{
document.all.ObjTableInfo.NumCols = arr["NumCols"];
}
else if ("BorderLineWidth" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "border="+arr["BorderLineWidth"]+" ";
}
else if ("CellSpacing" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellspacing="+arr["CellSpacing"]+" ";
}
else if ("CellPadding" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellpadding="+arr["CellPadding"]+" ";
}
else if ("TableWidth" == elem)
{
if(arr["TableWidthSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "width="+arr["TableWidth"];
if(arr["TableWidthMode"] == "%")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
}
else
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
}
}
}
else if ("TableHeight" == elem)
{
if(arr["TableHeigthSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "height="+arr["TableHeight"];
if(arr["TableHeightMode"] == "%")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
}
else
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
}
}
}
else if ("TableAlignment" == elem)
{
document.all.ObjTableInfo.CellAttrs = document.all.ObjTableInfo.CellAttrs + "align="+arr["TableAlignment"]+" ";
}
else if ("TableColor" == elem)
{
if(arr["TableColorSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "bgcolor="+arr["TableColor"];
}
}
else if ("Caption" == elem)
{
document.all.ObjTableInfo.Caption = arr["Caption"];
}
}
document.all.EDIT_HTML.ExecCommand(DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT, pVar);
}
}
function DECMD_HYPERLINK_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_PROMPTUSER);
EDITOR.EDIT_HTML.focus();
}
function DECMD_IMAGE_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_IMAGE,OLECMDEXECOPT_PROMPTUSER);
EDITOR.EDIT_HTML.focus();
}
function DECMD_HYPERLINK_NODIALOG_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_DONTPROMPTUSER, EDITOR.URL.value);
EDITOR.EDIT_HTML.focus();
}
function getChars(value) {
ret = "";
var num;
for(i=0;i<value.length;i++) {
num = value.charCodeAt(i);
if(num > 127) {
ret += "&#" + num.toString(10) + ";";
} else {
ret += value.charAt(i);
}
}
return ret + "";
}
// sends URL string from seperate browser window to a hidden field within the opener document
function sendURLString(destFormName,destFieldName,strURL){
var obj1='top.window.opener.self.document.'+ destFormName;
var obj2='top.window.opener.self.document.'+ destFormName +'.'+ destFieldName;
if (eval(obj1) && eval(obj2)) {
eval(obj2 +'.value="'+strURL+'"');
top.window.opener.doEditHTML(45);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -