多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 程序人生 > 隨筆 > phpcms編輯器添加一鍵排版控件

phpcms編輯器添加一鍵排版控件

來源:程序員人生   發布時間:2015-11-17 23:16:57 閱讀次數:10274次
CKEditor添加一鍵排版插件實例
大家都知道phpcms也是ckeditor編輯器,那么如果增加這個一鍵排版這個牛逼功能呢
增加好了后,效果圖是這樣的


廢話不多說,直接說步驟
第一步:config.js中statics\js\ckeditor\config.js中注冊autoformat控件
  1. config.extraPlugins = 'capture,videoforpc,flashplayer,autoformat'

第二步,在statics\js\ckeditor\plugins 新建文件夾autoformat

第三步,
statics\js\ckeditor\plugins\autoformat新建文件plugin.js
寫入如下內容
  1. /* 
  2. Copyright (c) 2015-11-17, 程序員人生 溫良順 
  3. http://www.vxbq.cn 
  4. */ 
  5. (function() { 
  6.     CKEDITOR.plugins.add('autoformat', { 
  7.         requires: ['styles''button'], 
  8.         init: function(a) { 
  9.             a.addCommand('autoformat', CKEDITOR.plugins.autoformat.commands.autoformat); 
  10.             a.ui.addButton('autoformat', { 
  11.                 label: "清除格式,一鍵排版"
  12.                 command: 'autoformat'
  13.                 icon: this.path + "autoformat.gif"//這個autoformat.gif是你的插件圖標,放在同目錄下 
  14.             }); 
  15.         } 
  16.     }); 
  17.     CKEDITOR.plugins.autoformat = { 
  18.         commands: { 
  19.             autoformat: { 
  20.                 exec: function(a) { 
  21.                     var _html = a.getData(); 
  22.                     //清除樣式代碼 
  23.                     _html = _html.replace(/<div/ig, '<p'); 
  24.                     _html = _html.replace(/<\/div>/ig, '</p>'); 
  25.                     _html = _html.replace(/<strong[^>]*>/ig, ''); 
  26.                     _html = _html.replace(/<\/strong>/ig, ''); 
  27.                     _html = _html.replace(/<em[^>]*>/ig, ''); 
  28.                     _html = _html.replace(/<\/em>/ig, ''); 
  29.                     _html = _html.replace(/<u[^>]*>/ig, ''); 
  30.                     _html = _html.replace(/<\/u>/, ''); 
  31.                     _html = _html.replace(/<li[^>]*>/ig, ''); 
  32.                     _html = _html.replace(/<\/li>/ig, ''); 
  33.                     _html = _html.replace(/<span[^>]*>/ig, ''); 
  34.                     _html = _html.replace(/<\/span>/ig, ''); 
  35.                     _html = _html.replace(/&nbsp;/ig, ''); 
  36.                     _html = _html.replace(/ /ig, ''); 
  37.                     _html = _html.replace(/<p><\/p>/ig, ''); 
  38.                     _html = _html.replace(/<a/ig, '<a rel="nofollow"'); 
  39.                      
  40.                      
  41.                     //將p標簽替換成<br /> 
  42.                     _html = _html.replace(/<p[^>]*>/ig,''); 
  43.                     _html = _html.replace(/<\/p>/ig,'<br />'); 
  44.                     _html = _html.replace(/<br \/><br \/>/ig,'<br />'); 
  45.                     _html = _html.replace(/[\n]/ig, ''); 
  46.                      
  47.                     //按<br />分組,將換行<br>全部替換成p標簽 
  48.                      bb = _html.split("<br />"); 
  49.                      aa=''
  50.                     for(var i=0;i<bb.length;i++){ 
  51.                        aa =aa+ '<p>'+bb[i]+'</p>'
  52.                       } 
  53.                      
  54.                     //首行縮進 
  55.                      _html = aa.replace(/<p[^>]*>/ig, '<p>  '); 
  56.                      _html = _html.replace(/<p>  <\/p>/ig,''); 
  57.                      _html = _html.replace(/<p><\/p>/ig,''); 
  58.  
  59.                     //在這里執行你將_html中的空行替換掉的操作 
  60.                        a.setData(_html); 
  61.                 } 
  62.             } 
  63.         } 
  64.     }; 
  65. })(); 


寫到這里,就完成啦,完成了CKEditor添加一鍵排版插件

但是,到這里再phpcms里面,還是不能直接用的,在別的系統里面是可以的。因為phpcms的編輯器控件是需要單獨選擇的,還需要修改phpcms文件
 
打開phpcms/libs/classes/form.class.php
搜索['Maximize'] 在它的后面加上 ['autoformat'],就可以了

這樣phpcms編輯器添加一鍵排版控件就完成啦,大家有什么疑問,歡迎留言,本文是站長手寫代碼,轉載請說明出處,本文來自程序員人生
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 99久久精品免费国产一区二区三区 | 羞羞网页登界面入口 | v片在线观看 | 精品国产理论在线观看不卡 | 天天视频国产 | 久草在线观看福利 | 五月丁香六月综合缴清无码 | 欧美精品成人 | 国产精品乱码免费一区二区 | 欧美三级视频在线播放 | 最新福利网站 | 国产精品福利视频一区二区三区 | 午夜手机福利 | 日本护士色xxxxx视频 | 在线黄色免费网站 | 男女激情视频在线观看 | 欧美xxxx在线 | 精品自拍视频在线观看 | 欧美精品综合一区二区三区 | 最近最新手机中文字幕在线看 | 大香伊蕉在人线国产75视频 | 在线免费观看成年人视频 | 亚洲国产成人久久三区 | 精品久久久久久国产 | 免费在线看v片 | 国产成人久久综合漫画 | 99福利网 | 欧美日韩高清一区 | 一二三四视频观看中文在线看 | 国产亚洲精品成人一区看片 | 一级毛片一级毛片a毛片欧美 | 国产日韩欧美亚洲综合在线 | 天堂最新版www在线观看 | 精品国产一区二区三区免费 | 国产精品亚洲综合 | 亚洲成人播放 | 亚洲一区二区三区四区视频 | 五月激情五月婷婷 | 爱爱免费视频网站 | 2022福利视频| 亚洲成a人片在线观看精品 亚洲成a人片在线观看尤物 |