📄 webhtmleditor.txt.exclude
字号:
this.AnalyseElem(elem,stackObject);
return stackObject.ToString();
} ;
ConvertHtmlToXhtmlFilter.prototype.HtmlEncode= function (s)
{
return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/\x22/g,""");
} ;
ConvertHtmlToXhtmlFilter.prototype.AnalyseAttribute= function (attribute,elem,stackObject)
{
if (!attribute.specified)
{
return;
}
var name=attribute.nodeName;
var value=attribute.nodeValue;
if (name != "style")
{
if (!isNaN(value))
{
value=elem["getAttribute"](name);
}
stackObject.Push("\x20"+(attribute.expando?name:name.toLowerCase())+"=\""+this.HtmlEncode(value)+"\"");
}
else
{
stackObject.Push(" style=\""+this.HtmlEncode(elem.style.cssText)+"\"");
}
} ;
ConvertHtmlToXhtmlFilter.prototype.AnalyseElem= function (elem,stackObject)
{
switch (elem.nodeType)
{
case 1:
if (elem.nodeName == "!")
{
stackObject.Push(elem.text);
break;
}
var name=elem.nodeName;
if (elem.scopeName)
{
if (elem.scopeName == "HTML")
{
name=name.toLowerCase();
}
}
else name=name.toLowerCase();
if ("td" == name||"tr" == name||"tbody" == name||"table" == name)
{
stackObject.Push("\x0a");
}
stackObject.Push("<"+name);
var attributeArray=elem.attributes;
var attributeArrayLen=attributeArray.length;
for (var i=0; i<attributeArrayLen; i++)
{
this.AnalyseAttribute(attributeArray[i],elem,stackObject);
}
if (elem.canHaveChildren||elem.hasChildNodes())
{
stackObject.Push(">");
var nodeList=elem.childNodes;
attributeArrayLen=nodeList.length;
for (var i=0; i<attributeArrayLen; i++)
{
this.AnalyseElem(nodeList[i],stackObject);
}
stackObject.Push("<\/"+name+">");
}
else if (name == "script")
{
stackObject.Push(">"+elem.text+"<\/"+name+">");
}
else if (name == "title"||name == "style"||name == "comment")
{
stackObject.Push(">"+elem.innerHTML+"<\/"+name+">");
}
else
{
stackObject.Push("\x20\/>");
}
break;
case 3:
stackObject.Push(String(elem.nodeValue).replace(/&/g,"&").replace(/</g,"<"));
break;
case 4:
stackObject.Push("<![CDA"+"TA[\x0a"+elem.nodeValue+"\x0a]"+"]>");
break;
case 8:
stackObject.Push(elem.text);
if (/(^<?xml)|(^<!DOCTYPE)/.test(elem.text))
{
stackObject.Push("\x0a");
}
break;
}
} ;
function ConvertHtmlToXhtmlFilterStack(str)
{
this.length=0;
this.ArrayIndex=0;
this.ArrayList=[];
this.Result=null;
if (str != null)
{
this.Push(str);
}
}
ConvertHtmlToXhtmlFilterStack.prototype.Push= function (str)
{
this.length+=(this.ArrayList[this.ArrayIndex++]=String(str)).length;
this.Result=null;
return this ;
}
ConvertHtmlToXhtmlFilterStack.prototype.ToString= function (str)
{
if (this.Result != null)
{
return this.Result;
}
var s=this.ArrayList.join("");
this.ArrayList=[s];
this.ArrayIndex=1;
this.length=s.length;
return this.Result=s;
}
function StripPathFilter(tagName,stripPath)
{
this.TagName=tagName;
this.Name="WebHtmlEditorStripPathFilter";
this.GetDesignContent=null;
this.GetPreviewContent=null;
this.Init(stripPath);
this.SetUrlAtt(this.TagName);
}
StripPathFilter.prototype.Init = function(stripPath)
{
this.StripPath=document.location.href;
this.urlArg=document.location.href;
var index=this.StripPath.indexOf("\/\/");
if (index>=0)
{
index=index+2;
index=this.StripPath.indexOf("\/",index);
}
this.StripPath=this.StripPath.substring(0,index);
this.urlArg=this.urlArg.replace(/&/ig,"&");
this.urlArg=this.urlArg.replace(/\?/ig,"\?");
if (stripPath != "")
{
this.StripPath=stripPath;
}
}
StripPathFilter.prototype.SetUrlAtt = function(tagName)
{
this.UrlAtt="";
switch (this.TagName)
{
case "IMG":
this.UrlAtt="src";
break;
case "A":
this.UrlAtt="href";
break;
}
}
StripPathFilter.prototype.ReplaceStrip = function(content,stripPath)
{
var regx=new RegExp("(<"+this.TagName+"[^<>]*?("+this.UrlAtt+")\s*=\s*['\"])("+stripPath+")([^'\"]*?['\"][^>]*?>)","ig");
var html = content.replace(regx,"$1$4");
return html;
}
StripPathFilter.prototype.GetHtmlContent = function(html)
{
if (!document.all)
{
return html;
}
if (this.TagName == "A")
{
var reg=new RegExp("(<A[^<>]*?(href)\s*=\s*['\"])("+this.urlArg+")(\#[^'\"]*?['\"][^>]*?>)","ig");
html=html.replace(reg,"$1$4");
}
return this.ReplaceStrip(html,this.StripPath);
}
function StripScriptTagsFilter()
{
this.AllowEnabled= true;
this.Name="WebHtmlEditorStripScriptTagsFilter";
this.GetPreviewContent=null;
}
StripScriptTagsFilter.prototype.Strip = function(html)
{
html=html.replace(/<(SCRIPT)([^>]*)\/>/gi,"");
html=html.replace(/<(SCRIPT)([^>]*)>[\s\S]*<\/(SCRIPT)([^>]*)>/gi,"");
var regx=new RegExp("<([^>]*)(runat\s*=\s*\"?server\"?)([^>]*)>","ig");
html=html.replace(regx,"<"+RegExp["$1"]+RegExp["$2"]+RegExp["$3"]+">");
html=html.replace("<"+"%","<%");
html=html.replace("%>","%>");
return html;
}
StripScriptTagsFilter.prototype.GetHtmlContent = function(html)
{
return this.Strip(html);
}
StripScriptTagsFilter.prototype.GetDesignContent = function(html)
{
return this.Strip(html);
}
StripScriptTagsFilter.prototype.GetPreviewContent = function(html)
{
return this.Strip(html);
}
function Font2SpanFilter()
{
this.AllowEnabled= true;
this.Name="WebHtmlEditorFont2SpanFilter";
this.GetPreviewContent=null;
this.FontSizeArray=["8pt","10pt","12pt","14pt","18pt","24pt","36pt"];
}
Font2SpanFilter.prototype.GetHtmlContent = function(html)
{
var span=document.createElement("SPAN");
span.innerHTML=html;
var tempspan=document.createElement("SPAN");
var span,font,parentNode;
var fontTags=span["getElementsByTagName"]("FONT");
while (fontTags.length>0)
{
font=fontTags[0];
parentNode=font.parentNode;
span=tempspan.cloneNode( false);
span.style.cssText=font.style.cssText;
if (font.className){span.className=font.className; }
if (font.face){span.style.fontFamily=font.face; }
var size=0;
if (font.style.fontSize)
{
span.style.fontSize=font.style.fontSize;
}
else if (!isNaN(size=parseInt(font.size)))
{
try
{
span.style.fontSize=this.FontSizeArray[size-1];
}
catch (ex)
{
span.style.fontSize=this.FontSizeArray[3];
}
}
if (font.color)
{
span.style.color=font.color;
}
span.innerHTML=font.innerHTML;
parentNode.insertBefore(span,font);
parentNode.removeChild(font);
fontTags=span["getElementsByTagName"]("FONT");
}
return span.innerHTML;
}
function ContextMenusManager(editor,customContextMenuArray)
{
this.Editor=editor;
this.LocalResources=this.Editor.LocalResources;
this.IsIE=this.Editor.IsIE;
this.Popup=BPopupsManager.GetPopupsManager();
this.Popup.AddStyleSheet(this.Editor.ThemePath +"/WebHtmlEditor.css");
this.Document=this.Popup.GetDocument();
this.selectedValue=null;
this.IsCreate= false;
//this.contextMenuArray=[["TABLE", true ,[[0x1 ,"ShowBorders",""],[0x1 ,"SetTableProperties",""],[0x1 ,"DeleteTable",""]]],["TD", true ,[[0x1 ,"InsertRowAbove",""],[0x1 ,"InsertRowBelow",""],[0x1 ,"DeleteRow",""],[0x1 ,"InsertColumnLeft",""],[0x1 ,"InsertColumnRight",""],[0x1 ,"DeleteColumn",""],[0x1 ,"MergeColumns",""],[0x1 ,"MergeRows",""],[0x3 ,"",""],[0x1 ,"SplitCell",""],[0x1 ,"DeleteCell",""],[0x1 ,"SetCellProperties",""],[0x1 ,"SetTableProperties",""],[0x1 ,"ShowBorders",""]]],["IMG", true ,[[0x1 ,"SetImageProperties",""]]],["A", true ,[[0x1 ,"LinkManager",""],[0x1 ,"Unlink",""]]],["*", true ,[[0x1 ,"Cut",""],[0x1 ,"Copy",""],[0x1 ,"Paste",""],[0x1 ,"PasteFromWord",""],[0x1 ,"PastePlainText",""],[0x1 ,"PasteAsHtml",""]]]];
this.contextMenuArray=[["TABLE", true ,[[0x1 ,"ShowBorders",""],[0x1 ,"SetTableProperties",""],[0x1 ,"DeleteTable",""]]],["TD", true ,[[0x1 ,"InsertRowAbove",""],[0x1 ,"InsertRowBelow",""],[0x1 ,"DeleteRow",""],[0x1 ,"InsertColumnLeft",""],[0x1 ,"InsertColumnRight",""],[0x1 ,"DeleteColumn",""],[0x1 ,"MergeColumns",""],[0x1 ,"MergeRows",""],[0x3 ,"",""],[0x1 ,"SplitCell",""],[0x1 ,"DeleteCell",""],[0x1 ,"SetCellProperties",""],[0x1 ,"SetTableProperties",""],[0x1 ,"ShowBorders",""]]],["A", true ,[[0x1 ,"LinkManager",""],[0x1 ,"Unlink",""]]],["*", true ,[[0x1 ,"Cut",""],[0x1 ,"Copy",""],[0x1 ,"Paste",""],[0x1 ,"PasteFromWord",""],[0x1 ,"PastePlainText",""],[0x1 ,"PasteAsHtml",""]]]];
if (customContextMenuArray&&customContextMenuArray.length>0)
{
this.contextMenuArray=this.contextMenuArray.concat(customContextMenuArray);
}
this.customContextMenuObjectArray=[];
}
ContextMenusManager.prototype.Create= function (e)
{
var menuArray=[];
for (var i=0; i<this.contextMenuArray.length; i++)
{
var contextMenuArray_Item = this.contextMenuArray[i];
var tagName = contextMenuArray_Item[0];
if ( false == contextMenuArray_Item[1])
{
menuArray[tagName] = null;
continue;
}
else
{
menuArray[tagName] = this.GetCustomContextMenuObject(contextMenuArray_Item[2]);
}
}
this.customContextMenuObjectArray = menuArray;
} ;
ContextMenusManager.prototype.GetCustomContextMenuObject= function (menuArray)
{
if (!menuArray||menuArray.length == 0)
{
return null;
}
var document=this.Document;
var table=this.GetTableElement();
var row = table.insertRow(table.rows.length);
var cell=row.insertCell(row.cells.length);
cell.style["width"] = "25px";
cell.innerHTML = " ";
cell.className = "WheContextMenuLogo";
cell = row.insertCell(row.cells.length);
var contextTable = this.Popup.CreateHtmlElement("TABLE");
contextTable.style["width"]="100%";
contextTable["cellSpacing"]=0;
contextTable["cellPadding"]=0;
cell.appendChild(contextTable);
var oToolArray=[];
var sep=0;
for (var i=0; i<menuArray.length; i++)
{
var item=menuArray[i];
var flagID=item[0];
var command=item[1];
var contextrow=contextTable.insertRow(contextTable.rows.length);
var contextcell=contextrow.insertCell(0);
if (flagID == ToolbarButtonTypes.Step)
{
SetSepLineCssClass(contextcell, true);
contextcell.className = "WheContextMenuSepHorizontal";
contextcell["setAttribute"]("align","center");
sep++;
}
else
{
var WebHtmlEditorTool=this.Editor.GetCustomToolbarButton(command, this, this.Document, null, null, true);
contextcell.appendChild(WebHtmlEditorTool.GetViewToolElem());
AddArrayListAtLast(oToolArray, WebHtmlEditorTool);
}
}
var height=3+(oToolArray.length*030)+(sep*5);
var customContextMenuObject= new Object();
customContextMenuObject.oToolList = oToolArray
customContextMenuObject.Width = 0272;
customContextMenuObject.Height = height;
customContextMenuObject.Table = table;
return customContextMenuObject;
} ;
ContextMenusManager.prototype.GetTableElement= function ()
{
var table=this.Popup.CreateHtmlElement("TABLE");
table.style["width"]=0265;
table["cellSpacing"]=0;
table["cellPadding"]=0;
table.style.cursor="default";
table.onselectstart="return false";
table.ondragstart="return false";
table.className="WheContextMenu";
return table;
};
ContextMenusManager.prototype.Clear= function ()
{
for (var j=0; j<this.customContextMenuObjectArray.length; j++)
{
var customContextMenuObject=this.customContextMenuObjectArray[j];
for (var i=0; i<customContextMenuObject.oToolList.length; i++)
{
customContextMenuObject.oToolList[i].Clear();
}
customContextMenuObject.Table=null;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -