难道整个csdn每一人回答?难道这个编译器每一人在用,天啊,我快疯了

解决方案 »

  1.   

    晚来的一年,不好意思,大家有用到的拿去看去吧
    CKEDITOR.plugins.add('search',{ //注册插件核心函数
        init: function(editor){
            var aricleList = 'aricleList';//文章列表
    var hotArticle="hotArticle";//热点文章
    var relatedArticles="relatedArticles";//相关文章
    var columnList="columnList";//栏目列表
    var columnNavigation="columnNavigation";//栏目导航
    var pageNavigation="pageNavigation";//分页导航
    var previous="previous";//上一篇
    var underA="underA";//下一篇
    var articlesNum="articlesNum";//文章条数
    var htmlFragment="htmlFragment";//html碎片
    var columnsRelated="columnsRelated";//栏目相关
    var editNickname="editNickname";//编辑昵称
            var aricleTitle="aricleTitle";//文章标题
    var pageTitle="pageTitle";//首页标题
    var columnTitle="columnTitle";//栏目标题
    var articleSubtitle="articleSubtitle";//文章副标题
    var articleAuther="articleAuther";//文章作者
    var articleSource="articleSource";//文章来源
    var articleSummary="articleSummary";//文章摘要
            var aricleContent="aricleContent";//文章内容
            var articleData="articleData";//文章日期
    var articleImage="articleImage";//文章缩略图1
            var articleImageTwo="articleImageTwo";//文章缩略图2
    var insertImage="insertImage";//插入图像
    var moreTags="moreTags";//更多标记
    var editHeaderInformation="editHeaderInformation";//编辑头部信息
    var modifiedMark='modifiedMark';
         editor.addCommand(aricleList, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){ //这里不需要对话框,所以直接用用匿名函数实现命令的逻辑
            //var text = editor.getSelection().getStartElement().getText();  //获得当前ckeditor编辑框中选定的dom元素的文本,这里还需要改进
            //window.open("module/tjt","name1","width=1000,height=400,toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=100");
            var options={options:{width:100,height:100}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            var url='/'+pathReally+'/menu/right/right.jsp?id=1';
            $.pdialog.open(url, "articlelist","文章列表",options);
           }
        })
       );
       
       editor.addCommand(modifiedMark, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){ //修改标记
            var element = editor.getSelection().getSelectedElement();
    var str=element.getAttribute('name');
    var strNum=str.split('[');
    var mainLabel=strNum[2].split(']')[0];
    var url='';
    var title='';
    var strPath=window.document.location.pathname;
    var pathReally=strPath.split('/')[1];
    var heightK=0,widthK=0;
    //str=escape(str);
    if(mainLabel=='ARTICLE_LIST'){
    url='/'+pathReally+'/menu/right/right.jsp?id=1&='+str;
    title='文章列表';
    heightK=400;
    widthK=600;
    }
    if(mainLabel=='ARTICLE_TOP'){
    url='/'+pathReally+'/menu/right/right.jsp?id=2&='+str;
    title='热点文章';
    heightK=400;
    widthK=600;
    }
    if(mainLabel=='RELATED_ARTICLE'){
    url='/'+pathReally+'/menu/right/right.jsp?id=3&='+str;
    title='相关文章';
    heightK=400;
    widthK=600;
    }
    if(mainLabel=='ARTICLE_COUNT'){
    url='/'+pathReally+'/menu/right/right.jsp?id=4&='+str;
    title="文章条数";
    heightK=400;
    widthK=600;
    }
    if(mainLabel=='COLUMN_LIST'){
    url='/'+pathReally+'/menu/right/right.jsp?id=5&='+str;
    title="栏目列表";
    heightK=400;
    widthK=600;
    }
    if(mainLabel=='COLUMN_PATH'){
    url='editMark/moduleColumnNacigation?='+str;
    title="栏目导航";
    heightK=130;
    widthK=300;
    }
    if(mainLabel=='NAVBAR'){
    url='editMark/modulePageNavigation?='+str;
    title="分页导航";
    heightK=130;
    widthK=300;
    }
    if(mainLabel=='PREV_ARTICLE'){
    url='editMark/modulePrevious?='+str;
    title="上一篇";
    heightK=130;
    widthK=300;
    }
    if(mainLabel=='NEXT_ARTICLE'){
    url='editMark/moduleUnderA?='+str;
    title="下一篇";
    heightK=130;
    widthK=300;
    }
    if(mainLabel=='PIC'){
    url='/'+pathReally+'/menu/right/insertImage.jsp?='+str;
    title="图像";
    heightK=400;
    widthK=400;
    }
            var options={options:{width:widthK,height:heightK,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            $.pdialog.open(url, "custom",title,options);
           }
        })
       );
         
        editor.addCommand(hotArticle, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:750,height:450,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/right.jsp?id=2', "2","热点文章",options);
           }
        })
       );
         
        editor.addCommand(relatedArticles, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:650,height:400,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/right.jsp?id=3', "3","相关文章",options);
           }
        })
       );
        
        editor.addCommand(columnNavigation, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:300,height:130,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            $.pdialog.open('editMark/moduleColumnNacigation', "4","栏目导航",options);
           }
        })
       );
       
       editor.addCommand(pageNavigation, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:300,height:130,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            $.pdialog.open('editMark/modulePageNavigation', "5","分页导航",options);
           }
        })
       );
       
        editor.addCommand(previous, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:300,height:130,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            $.pdialog.open('editMark/modulePrevious', "6","上一篇",options);
           }
        })
       );
       
       editor.addCommand(underA, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:300,height:130,max:false,mask:true,mixable:true,minable:true,resizable:false,drawable:false,fresh:false,close:"function", param:"{msg:'message'}"}};
            $.pdialog.open('editMark/moduleUnderA', "7","下一篇",options);
           }
        })
       ); 
       
       editor.addCommand(editNickname, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][EDITOR_NICKNAME][/EDITOR_NICKNAME][/MARK]");//编辑昵称
           }
        })
       );
         
        editor.addCommand(aricleTitle, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][MAINTITLE][/MAINTITLE][/MARK]");//文章标题
           }
        })
       );
       
       editor.addCommand(pageTitle, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][INDEXTITLE][/INDEXTITLE][/MARK]");//首页标题
           }
        })
       );
       
       editor.addCommand(columnTitle, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][COLUMNTITLE][/COLUMNTITLE][/MARK]");//栏目标题
           }
        })
       );
       
       editor.addCommand(articleSubtitle, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][VICETITLE][/VICETITLE][/MARK]");//文章副标题标题
           }
        })
       );
       
       editor.addCommand(articleAuther, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][AUTHOR][/AUTHOR][/MARK]");//文章作者
           }
        })
       );
       
       editor.addCommand(articleSource, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            editor.getSelection().getStartElement().appendHtml("[MARK][SOURCE][/SOURCE][/MARK]");//文章来源
           }
        })
       );
       
       editor.addCommand(aricleContent, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][CONTENT][/CONTENT][/MARK]");//文章内容
           }
        })
       );
       
       editor.addCommand(articleData, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][DATE]yyyy-MM-dd HH:mm:ss[/DATE][/MARK]");//文章日期
           }
        })
       );
       
       editor.addCommand(articleImage, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][THUMB_IMAGE][/THUMB_IMAGE][/MARK]");//文章日期
           }
        })
       );
       
       editor.addCommand(articleImage, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][THUMB_IMAGE][/THUMB_IMAGE][/MARK]");//文章缩略图1
           }
        })
       );
      

  2.   

    editor.addCommand(articleImageTwo, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][THUMB_IMAGE2][/THUMB_IMAGE2][/MARK]");//文章缩略图2
           }
        })
       );
       
       editor.addCommand(articleImageTwo, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        editor.getSelection().getStartElement().appendHtml("[MARK][THUMB_IMAGE2][/THUMB_IMAGE2][/MARK]");//文章缩略图2
           }
        })
       );
       
       editor.addCommand(editHeaderInformation, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
            var options={options:{width:530,height:350,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            $.pdialog.open('editMark/editHeaderInformation', "8","编辑模板头信息",options);
           }
        })
       );
       
        editor.addCommand(columnList, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){ 
        var options={options:{width:550,height:400,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/right.jsp?id=5', "9","栏目列表",options);
           }
        })
       );
        
        editor.addCommand(columnsRelated, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        var options={options:{width:200,height:200,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/columns_related.jsp', "10","栏目相关",options);
           }
        })
       );
       
       editor.addCommand(moreTags, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        var options={options:{width:200,height:200,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/moreTags.jsp', "11","更多标记",options);
           }
        })
       );
       
       editor.addCommand(articlesNum, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        var options={options:{width:650,height:400,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/right.jsp?id=4', "12","文章条数",options);
           }
        })
       );
       editor.addCommand(insertImage, new CKEDITOR.command( editor, { //注册命令
            exec : function( editor ){
        var options={options:{width:450,height:300,max:false,mask:true,mixable:true,minable:true,resizable:true,drawable:true,fresh:true}};
            var strPath=window.document.location.pathname;
            var pathReally=strPath.split('/')[1];
            $.pdialog.open('/'+pathReally+'/menu/right/insertImage.jsp', "13","图像",options);
           }
        })
       );
       
      if(editor.addMenuItems){  //添加menu子项
      editor.addMenuItems(  //have to add menu item first
           {
               aricleList:  //name of the menu item
               {
                   label: '文章列表',  
                   command: 'aricleList', //点击执行的命令
                   group: 'search',  //通过group可以设定本菜单项所属的组,多个组结合可以实现多层菜单。虽然这里不需要多层菜单,但是group必须定义
                   order: 3
                   
               },
       hotArticle:  //name of the menu item
               {
                   label: '热点文章',  
                   command: 'hotArticle',
                   group: 'search',
                   order : 4
               },
               relatedArticles:  //name of the menu item
               {
                   label: '相关文章',  
                   command: 'relatedArticles',
                   group: 'search',
                   order : 5
               },
               columnNavigation:  //name of the menu item
               {
                   label: '栏目导航',  
                   command: 'columnNavigation',
                   group: 'search',
                   order : 6
               },
               pageNavigation:  //name of the menu item
               {
                   label: '分页导航',  
                   command: 'pageNavigation',
                   group: 'search',
                   order : 7
               },
               previous:  //name of the menu item
               {
                   label: '上一篇',  
                   command: 'previous',
                   group: 'search',
                   order : 8
               },
               underA:  //name of the menu item
               {
                   label: '下一篇',  
                   command: 'underA',
                   group: 'search',
                   order :9
               },
               columnsRelated:  //name of the menu item
               {
                   label: '栏目相关',  
                   command: 'columnsRelated',
                   group: 'search',
                   order : 10
               },
               editNickname:  //name of the menu item
               {
                   label: '编辑昵称',  
                   command: 'editNickname',
                   group: 'search',
                   order : 11
               },
               aricleTitle:  //name of the menu item
               {
                   label: '文章标题',  
                   command: 'aricleTitle',
                   group: 'search',
                   order : 24
               },
               aricleContent:  //name of the menu item
               {
                   label: '文章内容',  
                   command: 'aricleContent',
                   group: 'search',
                   order : 3
               },
               columnList:  //name of the menu item
               {
                   label: '栏目列表',  
                   command: 'columnList',
                   group: 'search',
                   order : 14
               },
               pageTitle:  //name of the menu item
               {
                   label: '首页标题',  
                   command: 'pageTitle',
                   group: 'search',
                   order : 15
               },
               columnTitle:  //name of the menu item
               {
                   label: '栏目标题',  
                   command: 'columnTitle',
                   group: 'search',
                   order : 16
               },
               articleSubtitle:  //name of the menu item
               {
                   label: '文章副标题',  
                   command: 'articleSubtitle',
                   group: 'search',
                   order : 17
               },
               articleAuther:  //name of the menu item
               {
                   label: '文章作者',  
                   command: 'articleAuther',
                   group: 'search',
                   order : 18
               },
               articleSource:  //name of the menu item
               {
                   label: '文章来源',  
                   command: 'articleSource',
                   group: 'search',
                   order : 19
               },
               articleData:  //name of the menu item
               {
                   label: '文章日期',  
                   command: 'articleData',
                   group: 'search',
                   order : 20
               },
               articleImage:  //name of the menu item
               {
                   label: '文章缩略图1',  
                   command: 'articleImage',
                   group: 'search',
                   order : 21
               },
               articleImageTwo:  //name of the menu item
               {
                   label: '文章缩略图2',  
                   command: 'articleImageTwo',
                   group: 'search',
                   order : 22
               },
               editHeaderInformation:  //name of the menu item
               {
                   label: '编辑头部信息',  
                   command: 'editHeaderInformation',
                   group: 'search',
                   order: 2
               },
               moreTags:  //name of the menu item
               {
                   label: '更多标记',  
                   command: 'moreTags',
                   group: 'search',
                   order : 23
               },
               articlesNum:  //name of the menu item
               {
                   label: '文章条数',  
                   command: 'articlesNum',
                   group: 'search',
                   order : 12
               },
               modifiedMark:  //name of the menu item
               {
                   label: '修改标记',  
                   command: 'modifiedMark',
                   group: 'search',
                   order : 25
               },
               insertImage:  //name of the menu item
               {
                   label: '图像',  
                   command: 'insertImage',
                   group: 'search',
                   order :26
               },
      

  3.   

               insertMark:  //name of the menu item
               {
                   label: '插入标记',  
                   group: 'search',
                   order : 1,
                   getItems : function()
    {
                  if(document.getElementsByName("modelType")[0].checked==true){
                 return {aricleList: CKEDITOR.TRISTATE_ON,hotArticle: CKEDITOR.TRISTATE_ON,relatedArticles: CKEDITOR.TRISTATE_ON,columnNavigation: CKEDITOR.TRISTATE_ON,
                pageNavigation: CKEDITOR.TRISTATE_ON,previous: CKEDITOR.TRISTATE_DISABLED,underA: CKEDITOR.TRISTATE_DISABLED,articlesNum: CKEDITOR.TRISTATE_ON,columnsRelated: CKEDITOR.TRISTATE_ON,editNickname: CKEDITOR.TRISTATE_ON,pageTitle: CKEDITOR.TRISTATE_DISABLED,columnTitle: CKEDITOR.TRISTATE_DISABLED,articleSubtitle: CKEDITOR.TRISTATE_DISABLED,articleAuther: CKEDITOR.TRISTATE_DISABLED,articleSource: CKEDITOR.TRISTATE_DISABLED,articleData: CKEDITOR.TRISTATE_DISABLED,articleImage: CKEDITOR.TRISTATE_DISABLED,articleImageTwo: CKEDITOR.TRISTATE_DISABLED,
                aricleTitle: CKEDITOR.TRISTATE_DISABLED,aricleContent: CKEDITOR.TRISTATE_DISABLED,columnList: CKEDITOR.TRISTATE_ON,moreTags: CKEDITOR.TRISTATE_DISABLED,insertImage: CKEDITOR.TRISTATE_DISABLED};
                }else{
                return {aricleList: CKEDITOR.TRISTATE_ON,hotArticle: CKEDITOR.TRISTATE_ON,relatedArticles: CKEDITOR.TRISTATE_ON,columnNavigation: CKEDITOR.TRISTATE_ON,
                pageNavigation: CKEDITOR.TRISTATE_ON,previous: CKEDITOR.TRISTATE_ON,underA: CKEDITOR.TRISTATE_ON,articlesNum: CKEDITOR.TRISTATE_ON,columnsRelated: CKEDITOR.TRISTATE_ON,editNickname: CKEDITOR.TRISTATE_ON,pageTitle: CKEDITOR.TRISTATE_ON,columnTitle: CKEDITOR.TRISTATE_ON,articleSubtitle: CKEDITOR.TRISTATE_ON,articleAuther: CKEDITOR.TRISTATE_ON,articleSource: CKEDITOR.TRISTATE_ON,articleData: CKEDITOR.TRISTATE_ON,articleImage: CKEDITOR.TRISTATE_ON,articleImageTwo: CKEDITOR.TRISTATE_ON,
                aricleTitle: CKEDITOR.TRISTATE_ON,aricleContent: CKEDITOR.TRISTATE_ON,columnList: CKEDITOR.TRISTATE_ON,moreTags: CKEDITOR.TRISTATE_ON,insertImage: CKEDITOR.TRISTATE_ON};
                }

    }
               }
               
           });
    }
    if(editor.contextMenu){
           editor.contextMenu.addListener(function(element, selection){  //添加右键菜单响应
               if(! element ){ //如果在ckeditor编辑框内元素之外的地方按右键,不会反回任何信息(即不显示该菜单项)
                      return null;
               }
                var elements = editor.getSelection().getSelectedElement();
             if(elements!=null && elements.getAttribute("type")=='button'){//如果实在button按钮上右键那就显示修改标记
             return {modifiedMark: CKEDITOR.TRISTATE_ON};
             }else{//否则不显示修改标记显示插入标记
             return {insertMark : CKEDITOR.TRISTATE_ON,editHeaderInformation : CKEDITOR.TRISTATE_ON};
             }
    //TRISTATE_ON意味着该菜单项可用,如果是TRISTATE_OFF则是灰色的不可用,TRISTATE_DISABLED彻底不能用
           });
       }           
         }
    });