📄 editor2.js
字号:
// JavaScript Document
/***********************************************************
InnovaStudio WYSIWYG Editor 2.2
Copyright ?2003-2005, INNOVA STUDIO (www.InnovaStudio.com). All rights reserved.
************************************************************/
/*** UTILITY OBJECT ***/
var oUtil=new InnovaEditorUtil();
function InnovaEditorUtil()
{
/*** Localization ***/
this.langDir="english";
try{if(LanguageDirectory)this.langDir=LanguageDirectory;}catch(e){;}
var oScripts=document.getElementsByTagName("script");
for(var i=0;i<oScripts.length;i++)
{
var sSrc=oScripts[i].src.toLowerCase();
if(sSrc.indexOf("scripts/editor.js")!=-1) this.scriptPath=oScripts[i].src.replace(/editor.js/ig,"");
}
this.scriptPathLang=this.scriptPath+"language/"+this.langDir+"/";
if(this.langDir=="english")
document.write("<scr"+"ipt src='"+this.scriptPathLang+"editor_lang.js'></scr"+"ipt>");
/*** /Localization ***/
this.oName;this.oEditor;this.obj;
this.oSel;
this.sType;
this.bInside=bInside;
this.useSelection=true;
this.arrEditor=[];
this.onSelectionChanged=function(){return true;};
this.activeElement;
}
/*** FOCUS STUFF ***/
function bInside(oElement)
{
while(oElement!=null)
{
if(oElement.contentEditable=="true")return true;
oElement=oElement.parentElement;
}
return false;
}
function checkFocus()
{
var oEditor=eval("idContent"+this.oName);
var oSel=oEditor.document.selection.createRange();
var sType=oEditor.document.selection.type;
if(oSel.parentElement!=null)
{
if(!bInside(oSel.parentElement()))return false;
}
else
{
if(!bInside(oSel.item(0)))return false;
}
return true;
}
function iwe_focus()
{
var oEditor=eval("idContent"+this.oName);
oEditor.focus()
}
/*********************
EDITOR OBJECT
**********************/
function InnovaEditor(oName)
{
this.oName=oName;
this.RENDER=RENDER;
this.IsSecurityRestricted=false;
this.loadHTML=loadHTML;
this.getHTMLBody=getHTMLBody;
this.getXHTMLBody=getXHTMLBody;
this.getHTML=getHTML;
this.getXHTML=getXHTML;
this.putHTML=putHTML;//source dialog
this.css="";
this.initialRefresh=false;
this.bInside=bInside;
this.checkFocus=checkFocus;
this.focus=iwe_focus;
this.doCmd=doCmd;
this.applyParagraph=applyParagraph;
this.applyFontName=applyFontName;
this.applyFontSize=applyFontSize;
this.applyBullets=applyBullets;
this.applyNumbering=applyNumbering;
this.applyJustifyLeft=applyJustifyLeft;
this.applyJustifyCenter=applyJustifyCenter;
this.applyJustifyRight=applyJustifyRight;
this.applyJustifyFull=applyJustifyFull;
this.applyBlockDirLTR=applyBlockDirLTR;
this.applyBlockDirRTL=applyBlockDirRTL;
this.doPaste=doPaste;
this.doPasteText=doPasteText;
this.applySpan=applySpan;
this.makeAbsolute=makeAbsolute;
this.insertHTML=insertHTML;
this.clearAll=clearAll;
this.spellcheckDialogShow=spellcheckDialogShow;
this.insertCustomTag=insertCustomTag;
this.selectParagraph=selectParagraph;
this.doOnPaste=doOnPaste;
this.isAfterPaste=false;
this.doClean=doClean;
this.hide=hide;
this.dropShow=dropShow;
this.width="663";
this.height="250";
this.publishingPath="";//ex."http://localhost/InnovaStudio/"
var oScripts=document.getElementsByTagName("script");
for(var i=0;i<oScripts.length;i++)
{
var sSrc=oScripts[i].src.toLowerCase();
if(sSrc.indexOf("scripts/editor.js")!=-1) this.scriptPath=sSrc.replace(/editor.js/,"");
}
this.iconPath="icons/";
this.iconWidth=25;this.iconHeight=24;
this.writeIconToggle=writeIconToggle;
this.writeIconStandard=writeIconStandard;
this.writeDropDown=writeDropDown;
this.writeBreakSpace=writeBreakSpace;
this.dropTopAdjustment=1;
this.runtimeBorder=runtimeBorder;
this.runtimeBorderOn=runtimeBorderOn;
this.runtimeBorderOff=runtimeBorderOff;
this.IsRuntimeBorderOn=true;
this.runtimeStyles=runtimeStyles;
this.applyColor=applyColor;
this.customColors=[];//["#ff4500","#ffa500","#808000","#4682b4","#1e90ff","#9400d3","#ff1493","#a9a9a9"];
this.oColor1 = new ColorPicker("oColor1",this.oName);//to call: oEdit1.oColor1
this.oColor2 = new ColorPicker("oColor2",this.oName);//rendered id: ...oColor1oEdit1
this.expandSelection=expandSelection;
this.fullScreen=fullScreen;
this.stateFullScreen=false;
this.onFullScreen=function(){return true;};
this.onNormalScreen=function(){return true;};
this.arrElm=new Array(300);
this.getElm=iwe_getElm;
this.features=[];
this.buttonMap=["Save","FullScreen","Preview","Print","Search","SpellCheck","|",
"Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
"ForeColor","BackColor","|","Bookmark","Hyperlink",
"CustomTag","Image","Flash","Media","ContentBlock","InternalLink","CustomObject","|",
"Table","Guidelines","Absolute","|","Characters","Line",
"Form","Clean","HTMLFullSource","HTMLSource","XHTMLFullSource",
"XHTMLSource","ClearAll","BRK",
"StyleAndFormatting","|","Paragraph","FontName","FontSize","|",
"Bold","Italic","Underline","Strikethrough","Superscript","Subscript","|",
"JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|",
"Numbering","Bullets","|","Indent","Outdent","LTR","RTL"];//complete, default
this.btnSave=false;this.btnPreview=true;this.btnFullScreen=true;this.btnPrint=false;this.btnSearch=true;
this.btnSpellCheck=false;this.btnTextFormatting=true;
this.btnListFormatting=true;this.btnBoxFormatting=true;this.btnParagraphFormatting=true;this.btnCssText=true;
this.btnStyles=false;this.btnParagraph=true;this.btnFontName=true;this.btnFontSize=true;
this.btnCut=true;this.btnCopy=true;this.btnPaste=true;this.btnPasteText=false;this.btnUndo=true;this.btnRedo=true;
this.btnBold=true;this.btnItalic=true;this.btnUnderline=true;
this.btnStrikethrough=false;this.btnSuperscript=false;this.btnSubscript=false;
this.btnJustifyLeft=true;this.btnJustifyCenter=true;this.btnJustifyRight=true;this.btnJustifyFull=true;
this.btnNumbering=true;this.btnBullets=true;this.btnIndent=true;this.btnOutdent=true;
this.btnLTR=false;this.btnRTL=false;this.btnForeColor=true;this.btnBackColor=true;
this.btnHyperlink=true;this.btnBookmark=true;this.btnCharacters=true;this.btnCustomTag=false;
this.btnImage=true;this.btnFlash=false;this.btnMedia=false;
this.btnTable=true;this.btnGuidelines=true;
this.btnAbsolute=true;this.btnPasteWord=true;this.btnLine=true;
this.btnForm=true;this.btnClean=true;
this.btnHTMLFullSource=false;this.btnHTMLSource=false;
this.btnXHTMLFullSource=false;this.btnXHTMLSource=true;
this.btnClearAll=false;
//*** CMS Features ***
this.cmdAssetManager="";
this.btnContentBlock=false;
this.cmdContentBlock=";";//needs ;
this.btnInternalLink=false;
this.cmdInternalLink=";";//needs ;
this.insertLink=insertLink;
this.btnCustomObject=false;
this.cmdCustomObject=";";//needs ;
//*****
this.arrStyle=[];
this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText.htm',360,380)");
this.addonCSSBuilder=addonCSSBuilder;
this.arrParagraph=[[getText("Heading 1"),"H1"],
[getText("Heading 2"),"H2"],
[getText("Heading 3"),"H3"],
[getText("Heading 4"),"H4"],
[getText("Heading 5"),"H5"],
[getText("Heading 6"),"H6"],
[getText("Preformatted"),"PRE"],
[getText("Normal (P)"),"P"],
[getText("Normal (DIV)"),"DIV"]];
this.arrFontName=["\u5B8B\u4F53","\u9ED1\u4F53","\u96B6\u4E66","Arial","Arial Black","Arial Narrow",
"Book Antiqua","Bookman Old Style",
"Century Gothic","Comic Sans MS","Courier New",
"Franklin Gothic Medium","Garamond","Georgia",
"Impact","Lucida Console","Lucida Sans","Lucida Unicode",
"Modern","Monotype Corsiva","Palatino Linotype",
"Roman","Script","Small Fonts","Symbol",
"Tahoma","Times New Roman","Trebuchet MS",
"Verdana","Webdings","Wingdings","Wingdings 2","Wingdings 3",
"serif","sans-serif","cursive","fantasy","monoscape"];
this.arrFontSize=[[getText("Size 1"),"1"],
[getText("Size 2"),"2"],
[getText("Size 3"),"3"],
[getText("Size 4"),"4"],
[getText("Size 5"),"5"],
[getText("Size 6"),"6"],
[getText("Size 7"),"7"]];
this.arrCustomTag=[];//eg.[["Full Name","{%full_name%}"],["Email","{%email%}"]];
this.docType="";
this.html="<html>";
this.headContent="";
this.preloadHTML="";
this.onSave=function(){return true;};
this.useBR=false;
this.useDIV=true;
this.doUndo=doUndo;
this.doRedo=doRedo;
this.saveForUndo=saveForUndo;
this.arrUndoList=[];
this.arrRedoList=[];
this.useTagSelector=true;
this.TagSelectorPosition="bottom";
this.moveTagSelector=moveTagSelector;
this.selectElement=selectElement;
this.removeTag=removeTag;
this.doClick_TabCreate=doClick_TabCreate;
this.doRefresh_TabCreate=doRefresh_TabCreate;
this.arrCustomButtons = [["CustomName1","alert(0)","caption here","btnSave.gif"],
["CustomName2","alert(0)","caption here","btnSave.gif"]];
this.onSelectionChanged=function(){return true;};
}
/*********************
ADD-ONS
**********************/
function addonCSSBuilder(bEnabled)
{
if(bEnabled)
this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText2.htm',430,462)");
else
this.onCustomCssShow = new Function("modelessDialogShow('"+this.scriptPath+"styles_cssText.htm',360,380)");
}
/*********************
UNDO/REDO
**********************/
function saveForUndo()
{
var oEditor=eval("idContent"+this.oName);
var obj=eval(this.oName);
if(obj.arrUndoList[0])
if(oEditor.document.body.innerHTML==obj.arrUndoList[0][0])return;
for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
obj.focus();
var oSel=oEditor.document.selection.createRange();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -