📄 textedit.htc
字号:
if (curr.className == "yToolbar"){
InitTB(curr);
yToolbars[yToolbars.length] = curr; //0.1
}
}
oLinkField = parent.document.getElementsByName(sLinkFieldName)[0]; //undefined!
if (ContentFlag.value == "0") {
//ContentEdit.value = oLinkField.value;
//ContentLoad.value = oLinkField.value;
ContentFlag.value = "1";
}
setMode("EDIT");
setLinkedField() ;
eWebEditor.document.body.onpaste = onPaste ;
eWebEditor.focus();
}
// 初始化一个工具栏上的按钮
function InitBtn(btn) {
btn.onmouseover = BtnMouseOver;
btn.onmouseout = BtnMouseOut;
btn.onmousedown = BtnMouseDown;
btn.onmouseup = BtnMouseUp;
btn.ondragstart = YCancelEvent;
btn.onselectstart = YCancelEvent;
btn.onselect = YCancelEvent;
btn.YUSERONCLICK = btn.onclick;
btn.onclick = YCancelEvent;
btn.YINITIALIZED = true;
return true;
}
//Initialize a toolbar.
function InitTB(y) {
// Set initial size of toolbar to that of the handle
y.TBWidth = 0;
// Populate the toolbar with its contents
if (! PopulateTB(y)) return false;
// Set the toolbar width and put in the handle
y.style.posWidth = y.TBWidth;
return true;
}
// Hander that simply cancels an event
function YCancelEvent() {
event.returnValue=false;
event.cancelBubble=true;
return false;
}
// Toolbar button onmouseover handler
function BtnMouseOver() {
if (event.srcElement.tagName != "IMG") return false;
var image = event.srcElement;
var element = image.parentElement;
// Change button look based on current state of image.
if (image.className == "Ico") element.className = "BtnMouseOverUp";
else if (image.className == "IcoDown") element.className = "BtnMouseOverDown";
event.cancelBubble = true;
}
// Toolbar button onmouseout handler
function BtnMouseOut() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
yRaisedElement = null;
element.className = "Btn";
image.className = "Ico";
event.cancelBubble = true;
}
// Toolbar button onmousedown handler
function BtnMouseDown() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
event.returnValue=false;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
element.className = "BtnMouseOverDown";
image.className = "IcoDown";
event.cancelBubble = true;
event.returnValue = false;
return false;
}
// Toolbar button onmouseup handler
function BtnMouseUp() {
if (event.srcElement.tagName != "IMG") {
event.cancelBubble = true;
return false;
}
var image = event.srcElement;
var element = image.parentElement;
if (element.YUSERONCLICK)
eval(element.YUSERONCLICK + "anonymous()");
element.className = "BtnMouseOverUp";
image.className = "Ico";
event.cancelBubble = true;
return false;
}
// Populate a toolbar with the elements within it
function PopulateTB(y) {
var i, elements, element;
// Iterate through all the top-level elements in the toolbar
elements = y.children;
for (i=0; i < elements.length; i++) {
element = elements[i];
if (element.tagName == "SCRIPT" || element.tagName == "!") continue;
switch (element.className) {
case "Btn":
if (element.YINITIALIZED == null) { //没定义时为null
if (! InitBtn(element)) {
alert("Problem initializing:" + element.id);
return false;
}
}
element.style.posLeft = y.TBWidth;
y.TBWidth += element.offsetWidth + 1;
break;
case "TBGen":
element.style.posLeft = y.TBWidth;
y.TBWidth += element.offsetWidth + 1;
break;
case "TBSep": //null div
element.style.posLeft = y.TBWidth + 2;
y.TBWidth += 5;
break;
case "TBHandle":
element.style.posLeft = 2;
y.TBWidth += element.offsetWidth + 7;
break;
default:
alert("Invalid class: " + element.className + " on Element: " + element.id + " <" + element.tagName + ">");
return false;
}
}
y.TBWidth += 1;
return true;
}
// 设置所属表单的提交或reset事件
function setLinkedField() {
if (! oLinkField) return ;
var oForm = oLinkField.form ;
if (!oForm) return ;
// 附加submit事件
oForm.attachEvent("onsubmit", AttachSubmit) ;
if (! oForm.submitEditor) oForm.submitEditor = new Array() ;
oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ;
if (! oForm.originalSubmit) {
oForm.originalSubmit = oForm.submit ;
oForm.submit = function() {
if (this.submitEditor) {
for (var i = 0 ; i < this.submitEditor.length ; i++) {
this.submitEditor[i]() ;
}
}
this.originalSubmit() ;
}
}
// 附加reset事件
oForm.attachEvent("onreset", AttachReset) ;
if (! oForm.resetEditor) oForm.resetEditor = new Array() ;
oForm.resetEditor[oForm.resetEditor.length] = AttachReset ;
if (! oForm.originalReset) {
oForm.originalReset = oForm.reset ;
oForm.reset = function() {
if (this.resetEditor) {
for (var i = 0 ; i < this.resetEditor.length ; i++) {
this.resetEditor[i]() ;
}
}
this.originalReset() ;
}
}
}
// 附加submit提交事件,大表单数据提交,远程文件获取,保存eWebEditor中的内容
var bDoneAutoRemote = false;
function AttachSubmit() {
alert("21");
var oForm = oLinkField.form ;
if (!oForm) return;
if ((config.AutoRemote=="1")&&(!bDoneAutoRemote)){
parent.event.returnValue = false;
bDoneAutoRemote = true;
remoteUpload();
} else {
var html = getHTML();
ContentEdit.value = html;
if (sCurrMode=="TEXT"){
html = HTMLEncode(html);
}
splitTextField(oLinkField, html);
}
}
// 提交表单
function doSubmit(){
alert("22");
var oForm = oLinkField.form ;
if (!oForm) return ;
oForm.submit();
}
// 附加Reset事件
function AttachReset() {
alert("20")
if (!bEditMode) setMode('EDIT');
if(bEditMode){
eWebEditor.document.body.innerHTML = ContentLoad.value;
}else{
eWebEditor.document.body.innerText = ContentLoad.value;
}
}
// 粘贴时自动检测是否来源于Word格式
function onPaste()
{
format('backcolor','#ffffff');
//alert("liupengfe");
format('backcolor','#ffffff');
/*alert(window.clipboardData.getData("text"));
if (config.AutoDetectPasteFromWord && BrowserInfo.IsIE55OrMore) {
var sHTML = GetClipboardHTML() ;
alert(sHTML);
var re = /<\w[^>]* class="?MsoNormal"?/gi;
if ( re.test( sHTML ) )
{
if ( confirm( "你要粘贴的内容好象是从Word中拷出来的,是否要先清除Word格式再粘贴?" ) )
{
cleanAndPaste( sHTML ) ;
return false ;
}
}
}
else
return true ;*/
}
function GetClipboardHTML() {
/*var oDiv = eWebEditor_Temp_HTML;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -