📄 opencms_edithtml.js
字号:
/*
* File : $Source: /usr/local/cvs/opencms/etc/ocsetup/vfs/system/workplace/templates/js/opencms_edithtml.js,v $
* Date : $Date: 2002/09/03 11:57:00 $
* Version: $Revision: 1.28 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//------------------------------------------------------//
// Script for html editcontrol
//------------------------------------------------------//
var binlist=null;
// Definition of constants, which button is clicked
var CLOSE=1;
var SAVECLOSE=2;
var SAVE=3;
var UNDO=4;
var REDO=5;
//var SEARCH=6;
//var REPLACE=7;
var GOTO=8;
var CUT=9;
var COPY=10;
var PASTE=11;
var IMPORT=12;
var EXPORT=13;
var EXPORTAS=7;
var PRINT=15;
var FORMAT=21;
var FONTFACE=22;
var FONTSIZE=23;
var BOLD=24;
var ITALIC=25;
var UNDERLINE=26;
var ALIGNLEFT=31;
var ALIGNCENTER=32;
var ALIGNRIGHT=33;
var ULIST=34;
var OLIST=35;
var INDENTIN=36;
var INDENTOUT=37;
var FONTCOLOR=38;
var BACKCOLOR=39;
var TABLE=40;
var LINK=41;
var PIC=42;
var PICLIST=43;
// Command IDs for the MS DHTML controls
//
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
//
// Enums
//
// OLECMDEXECOPT
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
// DHTMLEDITCMDF
DECMDF_NOTSUPPORTED = 0
DECMDF_DISABLED = 1
DECMDF_ENABLED = 3
DECMDF_LATCHED = 7
DECMDF_NINCHED = 11
// DHTMLEDITAPPEARANCE
DEAPPEARANCE_FLAT = 0
DEAPPEARANCE_3D = 1
// OLE_TRISTATE
OLE_TRISTATE_UNCHECKED = 0
OLE_TRISTATE_CHECKED = 1
OLE_TRISTATE_GRAY = 2
<!-- Define Arrays for the context menue -->
var MENU_SEPARATOR = "";
var ContextMenu = new Array();
var GeneralContextMenu = new Array();
var TableContextMenu = new Array();
var AbsPosContextMenu = new Array();
<!-- Constructor for custom object that represents an item on the context menu -->
function ContextMenuItem(string, cmdId) {
this.string = string;
this.cmdId = cmdId;
}
<!-- Displays the Context menue, taken from the MS example editor -->
function ShowContextMenu() {
var menuStrings = new Array();
var menuStates = new Array();
var state;
var i
var idx = 0;
// Rebuild the context menu.
ContextMenu.length = 0;
// Always show general menu
for (i=0; i<GeneralContextMenu.length; i++) {
ContextMenu[idx++] = GeneralContextMenu[i];
}
// Is the selection inside a table? Add table menu if so
if (document.all.EDIT_HTML.QueryStatus(DECMD_INSERTROW) != DECMDF_DISABLED) {
for (i=0; i<TableContextMenu.length; i++) {
ContextMenu[idx++] = TableContextMenu[i];
}
}
// Set up the actual arrays that get passed to SetContextMenu
for (i=0; i<ContextMenu.length; i++) {
menuStrings[i] = ContextMenu[i].string;
if (menuStrings[i] != MENU_SEPARATOR) {
state = document.all.EDIT_HTML.QueryStatus(ContextMenu[i].cmdId);
} else {
state = DECMDF_ENABLED;
}
if (state == DECMDF_DISABLED || state == DECMDF_NOTSUPPORTED) {
menuStates[i] = OLE_TRISTATE_GRAY;
} else if (state == DECMDF_ENABLED || state == DECMDF_NINCHED) {
menuStates[i] = OLE_TRISTATE_UNCHECKED;
} else { // DECMDF_LATCHED
menuStates[i] = OLE_TRISTATE_CHECKED;
}
}
// Set the context menu
document.all.EDIT_HTML.SetContextMenu(menuStrings, menuStates);
}
<!-- Do the Action when a Context menu entry is selected. Taken from the MS example editor -->
function ContextMenuAction(itemIndex) {
if (ContextMenu[itemIndex].cmdId == DECMD_INSERTTABLE) {
InsertTable();
} else {
document.all.EDIT_HTML.ExecCommand(ContextMenu[itemIndex].cmdId, OLECMDEXECOPT_DODEFAULT);
}
}
function DisplayChanged()
{
var i, s;
s = document.all.EDIT_HTML.QueryStatus(DECMD_GETBLOCKFMT);
if (s == DECMDF_DISABLED || s == DECMDF_NOTSUPPORTED) {
document.all.BLOCK.disabled = true;
} else {
document.all.BLOCK.disabled = false;
document.all.BLOCK.value = document.all.EDIT_HTML.ExecCommand(DECMD_GETBLOCKFMT, OLECMDEXECOPT_DODEFAULT);
}
s = document.all.EDIT_HTML.QueryStatus(DECMD_GETFONTNAME);
if (s == DECMDF_DISABLED || s == DECMDF_NOTSUPPORTED) {
document.all.FONTFACE.disabled = true;
} else {
var value = document.all.EDIT_HTML.ExecCommand(DECMD_GETFONTNAME, OLECMDEXECOPT_DODEFAULT);
if ((value != null) && (USE_FONTFACE == true)) {
document.all.FONTFACE.disabled = false;
document.all.FONTFACE.value = value;
} else {
document.all.FONTFACE.disabled = true;
}
}
if (s == DECMDF_DISABLED || s == DECMDF_NOTSUPPORTED) {
document.all.FONTSIZE.disabled = true;
} else {
var value = document.all.EDIT_HTML.ExecCommand(DECMD_GETFONTSIZE, OLECMDEXECOPT_DODEFAULT);
if ((value != null) && (USE_FONTSIZE == true)) {
document.all.FONTSIZE.disabled = false;
document.all.FONTSIZE.value = value;
} else {
document.all.FONTSIZE.disabled = true;
}
}
if(document.activeElement != EDITOR.EDIT_HTML) {
EDITOR.EDIT_HTML.focus();
}
}
var linkEditor = null;
var linkEditorRange = null;
var linkEditorSelection = null;
var linkEditorStyleInputs = null;
// which button is clicked
function doEditHTML(para)
{
switch (para)
{
case CLOSE:
document.EDITOR.action.value = "exit";
document.EDITOR.target = "_top";
doSubmit();
document.EDITOR.submit();
//if (binlist!=null) binlist.close();
break;
case SAVECLOSE:
document.EDITOR.action.value = "saveexit";
document.EDITOR.target = "_top";
doSubmit();
document.EDITOR.submit();
//if (binlist!=null) binlist.close();
break;
case SAVE:
document.EDITOR.action.value = "save";
doSubmit();
document.EDITOR.submit();
break;
case 4:
DECMD_UNDO_onclick();
break;
case 5:
DECMD_REDO_onclick();
break;
case 6:
DECMD_FINDTEXT_onclick();
break;
case 7:
MENU_FILE_SAVEAS_onclick();
break;
case 8:
break;
case 9:
DECMD_CUT_onclick();
break;
case 10:
DECMD_COPY_onclick();
break;
case 11:
DECMD_PASTE_onclick();
break;
case 12:
MENU_FILE_IMPORT_onclick();
break;
case 13:
MENU_FILE_EXPORT_onclick();
break;
case 14:
MENU_FILE_SAVEAS_onclick();
break;
case 15:
EDITOR.EDIT_HTML.PrintDocument(true);
break;
case 21:
ParagraphStyle_onchange();
break;
case 22:
FontName_onchange();
break;
case 23:
FontSize_onchange();
break;
case 24:
DECMD_BOLD_onclick();
break;
case 25:
DECMD_ITALIC_onclick();
break;
case 26:
DECMD_UNDERLINE_onclick();
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -