📄 edit.js
字号:
window.onload=doInit
function doInit(){
// Ensure that all document elements except the content editable DIV are unselectable.
//for (i=0; i<document.all.length; i++)
//document.all(i).unselectable = "off";
var toolbar=document.getElementById("toolbar");
toolbar.unselectable="on";
var editor=document.getElementById ("editor");
editor.unselectable = "off";
// Clear any text in the Document window and set the focus.
//editor.focus();
}
function restore()
{
if(editor.innerHTML=="")
editor.innerHTML=window.clipboardData.getData("Text");
else
{
if (confirm("已有内容,是否覆盖?") == false)
return false;
else
editor.innerHTML=window.clipboardData.getData("Text");
}
}
function format(formatString)
{
document.execCommand(formatString);
}
function VerticalMode()
{
if (editor.style.writingMode == 'tb-rl')
editor.style.writingMode = 'lr-tb';
else
editor.style.writingMode = 'tb-rl';
}
function changeFontSize()
{
var fsize=document.getElementById ("FontSize");
var val=fsize[fsize.selectedIndex].value;
document.execCommand ("FontSize",false,val);
}
function changeFontName()
{
var fname=document.getElementById ("FontName");
var val=fname[fname.selectedIndex].value;
document.execCommand ("FontName",false,val);
}
function changeColor(cmdID)
{
var newcolor = showModalDialog("../edit/image/select_color.html", "Ffffff", "resizable: no; help: no; status: no; scroll: no;");
if (newcolor != null)
document.execCommand(cmdID, false, "#"+newcolor);
}
function CreateLink()
{
document.execCommand ("CreateLink",1);
}
function insertImage()
{
editor.focus();
showModalDialog("../edit/image/insert_image.html", document, "resizable: no;dialogHeight:200px;dialogWidth:400px; help: no; status: no; scroll: no; ");
}
function upImage()
{
editor.focus();
showModalDialog("../edit/up_image.html", document, "resizable: no;dialogHeight:300px;dialogWidth:400px; help: no; status: no; scroll: no; ");
}
function upFile()
{
editor.focus();
var iWidth=400; //模态窗口宽度
var iHeight=200;//模态窗口高度
var iTop=(window.screen.height-iHeight)/2;
var iLeft=(window.screen.width-iWidth)/2;
window.open("../edit/upfile.aspx","upfile",
"Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no, Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft) ;
}
function viewHtml()
{
var viewHtmlCheck=document.getElementById ("viewHtmlCheck");
if(viewHtmlCheck.checked)
{
editor.innerText=editor.innerHTML;
toolbar.style.display ="none";
}
else
{
editor.innerHTML =editor.innerText;
toolbar.style.display ="";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -