📄 editor.js
字号:
if (YuZi_BROWSER == 'IE') {
YuZi_EDITFORM_DOCUMENT.execCommand(cmd, false, value);
}
else {
BBSXPSelection();
BBSXPExecuteBackColor(value);
}
}
else {
if (value == 'YuZi_ForeColor') value = YuZi_ForeColor;
YuZi_EDITFORM_DOCUMENT.execCommand(cmd, false, value);
}
}
function BBSXPSimpleExecute(cmd,option)
{
BBSXPEditorForm.focus();
YuZi_EDITFORM_DOCUMENT.execCommand(cmd,false,option);
BBSXPDisableMenu();
}
//格式实现
function BBSXPExecute(cmd, value)
{
switch (cmd)
{
case 'Break':
BBSXPEditorForm.focus();
BBSXPSelection();
var element = document.createElement("br");
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_UNDO':
BBSXPSimpleExecute('undo');
break;
case 'YuZi_REDO':
BBSXPSimpleExecute('redo');
break;
case 'YuZi_CUT':
YuZi_BROWSER == 'IE' ? BBSXPSimpleExecute('cut') : alert(YuZi_LANG['CopyPaste']);
break;
case 'YuZi_COPY':
YuZi_BROWSER == 'IE' ? BBSXPSimpleExecute('copy') : alert(YuZi_LANG['CopyPaste']);
break;
case 'YuZi_PASTE':
YuZi_BROWSER == 'IE' ? BBSXPSimpleExecute('paste') : alert(YuZi_LANG['CopyPaste']);
break;
case 'YuZi_SELECTALL':
BBSXPSimpleExecute('selectall');
break;
case 'YuZi_UNSELECT':
BBSXPSimpleExecute('unselect');
break;
case 'YuZi_Paragraph':
BBSXPSimpleExecute('InsertParagraph');
break;
case 'YuZi_Delete':
BBSXPSimpleExecute('Delete');
break;
case 'YuZi_SUBSCRIPT':
BBSXPSimpleExecute('subscript');
break;
case 'YuZi_SUPERSCRIPT':
BBSXPSimpleExecute('superscript');
break;
case 'YuZi_BOLD':
BBSXPSimpleExecute('bold');
break;
case 'YuZi_ITALIC':
BBSXPSimpleExecute('italic');
break;
case 'YuZi_UNDERLINE':
BBSXPSimpleExecute('underline');
break;
case 'YuZi_STRIKE':
BBSXPSimpleExecute('strikethrough');
break;
case 'YuZi_JUSTIFYLEFT':
BBSXPSimpleExecute('justifyleft');
break;
case 'YuZi_JUSTIFYCENTER':
BBSXPSimpleExecute('justifycenter');
break;
case 'YuZi_JUSTIFYRIGHT':
BBSXPSimpleExecute('justifyright');
break;
case 'YuZi_JUSTIFYFULL':
BBSXPSimpleExecute('justifyfull');
break;
case 'YuZi_NUMBEREDLIST':
BBSXPSimpleExecute('insertorderedlist');
break;
case 'YuZi_UNORDERLIST':
BBSXPSimpleExecute('insertunorderedlist');
break;
case 'YuZi_INDENT':
BBSXPSimpleExecute('indent');
break;
case 'YuZi_OUTDENT':
BBSXPSimpleExecute('outdent');
break;
case 'YuZi_REMOVE':
BBSXPSimpleExecute('removeformat');
break;
case 'YuZi_ClearUP':
YuZi_EDITFORM_DOCUMENT.body.innerHTML = ClearCode(YuZi_EDITFORM_DOCUMENT.body.innerHTML,1);
break;
case 'YuZi_TITLE':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_TITLE_END':
BBSXPEditorForm.focus();
value = '<' + value + '>';
BBSXPSelect();
BBSXPExecuteValue('FormatBlock', value);
BBSXPDisableMenu();
break;
case 'YuZi_FONTNAME':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_FONTNAME_END':
BBSXPEditorForm.focus();
BBSXPSelect();
BBSXPExecuteValue('fontname', value);
BBSXPDisableMenu();
break;
case 'YuZi_FONTSIZE':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_FONTSIZE_END':
BBSXPEditorForm.focus();
value = value.substr(0, 1);
BBSXPSelect();
BBSXPExecuteValue('fontsize', value);
BBSXPDisableMenu();
break;
case 'YuZi_TEXTCOLOR':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_TEXTCOLOR_END':
BBSXPEditorForm.focus();
BBSXPSelect();
BBSXPExecuteValue('ForeColor', value);
BBSXPDisableMenu();
$('YuZi_TEXTCOLORBar').style.background = value;
YuZi_ForeColor = value;
break;
case 'YuZi_BGCOLOR':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_BGCOLOR_END':
BBSXPEditorForm.focus();
if (YuZi_BROWSER == 'IE') {
BBSXPSelect();
BBSXPExecuteValue('BackColor', value);
} else {
BBSXPExecuteBackColor(value)
}
BBSXPDisableMenu();
$('YuZi_BGCOLORBar').style.background = value;
YuZi_BackColor = value;
break;
case 'YuZi_ICON':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_ICON_END':
BBSXPEditorForm.focus();
var element = document.createElement("img");
element.src = value;
element.border = 0;
BBSXPSelect();
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_Replace':
BBSXPDisplayMenu(cmd);
BBSXPDrawIframe(cmd);
BBSXPYuZi_ReplaceIframe.focus();
YuZi_Replace_DOCUMENT.getElementById(cmd+'submitButton').focus();
break;
case 'YuZi_ED2K':
BBSXPDisplayMenu(cmd);
BBSXPDrawIframe(cmd);
BBSXPYuZi_ED2KIframe.focus();
YuZi_ED2K_DOCUMENT.getElementById(cmd+'submitButton').focus();
break;
case 'YuZi_IMAGE':
BBSXPDisplayMenu(cmd);
BBSXPDrawIframe(cmd);
BBSXPYuZi_IMAGEIframe.focus();
YuZi_IMAGE_DOCUMENT.getElementById(cmd+'submitButton').focus();
break;
case 'YuZi_Media':
BBSXPDisplayMenu(cmd);
BBSXPDrawIframe(cmd);
BBSXPYuZi_MediaIframe.focus();
YuZi_Media_DOCUMENT.getElementById(cmd+'submitButton').focus();
break;
case 'YuZi_LINK':
if (YuZi_BROWSER == 'IE') {
BBSXPSimpleExecute('createLink');
}
else {
BBSXPDisplayMenu(cmd);
BBSXPDrawIframe(cmd);
BBSXPYuZi_LINKIframe.focus();
YuZi_LINK_DOCUMENT.getElementById(cmd+'submitButton').focus();
}
break;
case 'YuZi_UNLINK':
BBSXPSimpleExecute('unlink');
break;
case 'YuZi_SPECIALCHAR':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_SPECIALCHAR_END':
BBSXPEditorForm.focus();
BBSXPSelect();
var element = document.createElement("span");
element.appendChild(document.createTextNode(value));
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_TABLE':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_TABLE_END':
BBSXPEditorForm.focus();
var location = value.split(',');
var element = document.createElement("table");
element.cellPadding = 0;
element.cellSpacing = 0;
element.border = 1;
element.style.width = "100%";
for (var i = 0; i < location[0]; i++) {
var rowElement = element.insertRow(i);
for (var j = 0; j < location[1]; j++) {
var cellElement = rowElement.insertCell(j);
cellElement.innerHTML = " ";
}
}
BBSXPSelect();
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_HR':
BBSXPDisplayMenu(cmd);
break;
case 'YuZi_HR_END':
BBSXPEditorForm.focus();
var element = document.createElement("hr");
element.width = "100%";
element.color = value;
element.size = 1;
BBSXPSelect();
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_DATE':
BBSXPEditorForm.focus();
BBSXPSelection();
var element = document.createElement("span");
element.appendChild(document.createTextNode(new Date().toLocaleDateString()));
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_TIME':
BBSXPEditorForm.focus();
BBSXPSelection();
var element = document.createElement("span");
element.appendChild(document.createTextNode(new Date().toLocaleTimeString()));
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
case 'YuZi_QUOTE':
BBSXPEditorForm.focus();
var element = document.createElement("span");
element.innerHTML = value;
BBSXPSelection();
BBSXPInsertItem(element);
BBSXPDisableMenu();
break;
default:
break;
}
}
// 改变模式:代码、编辑
function setMode(NewMode){
if(NewMode!=YuZi_CurrentMode){
YuZi_IsChangeMode = true;
var obj=$("BBSXPEditorIframe");
if(YuZi_TdHeight == -1)YuZi_TdHeight = parseInt(obj.offsetHeight);
switch(NewMode){
case 'DESIGN':
obj.style.height = (parseInt(obj.offsetHeight) - 55) + 'px';
YuZi_EDITFORM_DOCUMENT.body.innerHTML = BBSXPClearScriptTag($("BBSXPCodeForm").value);
$("BBSXPEditorForm").style.display = 'block';
$("BBSXPToolBar").style.display = 'block';
$("BBSXPCodeForm").style.display = 'none';
var EditorFormObject =$("BBSXPEditorForm");
EditorFormObject.style.height = parseInt(obj.offsetHeight) + 'px';
if (parseInt(EditorFormObject.offsetHeight)< YuZi_TdHeight){EditorFormObject.style.height = YuZi_TdHeight + 'px';}
break;
case 'CODE':
obj.style.height = (parseInt(obj.offsetHeight) + 51) + 'px';
$("BBSXPCodeForm").value = BBSXPHtmlToXhtml(YuZi_EDITFORM_DOCUMENT.body.innerHTML);
$("BBSXPToolBar").style.display = 'none';
$("BBSXPEditorForm").style.display = 'none';
$("BBSXPCodeForm").style.display = 'block';
$("BBSXPCodeForm").focus();
var CodeFormObject=$("BBSXPCodeForm");
CodeFormObject.style.height = parseInt(obj.offsetHeight) + 'px';
if (parseInt(CodeFormObject.offsetHeight)< YuZi_TdHeight){CodeFormObject.style.height = YuZi_TdHeight + 'px';}
break;
default:
break;
}
if (parseInt(obj.offsetHeight)< YuZi_TdHeight){obj.style.height = YuZi_TdHeight + 'px';}
try{
$("HtmlEditor_DESIGN").className = "StatusBarBtnOff";
$("HtmlEditor_CODE").className = "StatusBarBtnOff";
$("HtmlEditor_"+NewMode).className = "StatusBarBtnOn";
}
catch(e){
}
YuZi_CurrentMode = NewMode;
}
}
// 调整编辑器的大小
function ChangeSize(size){
var obj=$("BBSXPEditorIframe");
if(YuZi_TdHeight == -1)YuZi_TdHeight = parseInt(obj.offsetHeight);
obj.style.height = (parseInt(obj.offsetHeight) + size) + 'px';
if (parseInt(obj.offsetHeight)< YuZi_TdHeight){obj.style.height = YuZi_TdHeight + 'px';}
if (YuZi_IsChangeMode) {
if (YuZi_CurrentMode == 'DESIGN') {
obj=$("BBSXPEditorForm");
obj.style.height = (parseInt(obj.offsetHeight) + size) + 'px';
if (parseInt(obj.offsetHeight)< YuZi_TdHeight){obj.style.height = YuZi_TdHeight + 'px';}
}
else {
if (parseInt(obj.offsetHeight)< YuZi_TdHeight+77){obj.style.height = (YuZi_TdHeight+77) + 'px';}
obj=$("BBSXPCodeForm");
obj.style.height = (parseInt(obj.offsetHeight) + size) + 'px';
if (parseInt(obj.offsetHeight)< YuZi_TdHeight+77){obj.style.height = (YuZi_TdHeight+77) + 'px';}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -