CKEditor添加一键排版插件实例
大家都知道phpcms也是ckeditor编辑器,那么如果增加这个一键排版这个牛逼功能呢
增加好了后,效果图是这样的

废话不多说,直接说步骤
第一步:config.js中statics\js\ckeditor\config.js中注册autoformat控件

config.extraPlugins = 'capture,videoforpc,flashplayer,autoformat'; 

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

第三步,statics\js\ckeditor\plugins\autoformat新建文件plugin.js
写入如下内容

 (function() {
CKEDITOR.plugins.add('autoformat', {
requires: ['styles', 'button'],
init: function(a) {
a.addCommand('autoformat', CKEDITOR.plugins.autoformat.commands.autoformat);
a.ui.addButton('autoformat', {
label: "清除格式,一键排版",
command: 'autoformat',
//这个autoformat.gif是你的插件图标,放在同目录下
icon: this.path + "autoformat.gif"
});
}
});
CKEDITOR.plugins.autoformat = {
commands: {
autoformat: {
exec: function(a) {
var _html = a.getData();
//清除样式代码
_html = _html.replace(/<div/ig, '<p');
_html = _html.replace(/<\/div>/ig, '</p>');
_html = _html.replace(/<strong[^>]*>/ig, '');
_html = _html.replace(/<\/strong>/ig, '');
_html = _html.replace(/<em[^>]*>/ig, '');
_html = _html.replace(/<\/em>/ig, '');
_html = _html.replace(/<u[^>]*>/ig, '');
_html = _html.replace(/<\/u>/, '');
_html = _html.replace(/<li[^>]*>/ig, '');
_html = _html.replace(/<\/li>/ig, '');
_html = _html.replace(/<span[^>]*>/ig, '');
_html = _html.replace(/<\/span>/ig, '');
_html = _html.replace(/&nbsp;/ig, '');
_html = _html.replace(/ /ig, '');
_html = _html.replace(/<p><\/p>/ig, '');
_html = _html.replace(/<a/ig, '<a rel="nofollow"'); //将p标签替换成<br />
_html = _html.replace(/<p[^>]*>/ig, '');
_html = _html.replace(/<\/p>/ig, '<br />');
_html = _html.replace(/<br \/><br \/>/ig, '<br />');
_html = _html.replace(/[\n]/ig, ''); //按<br />分组,将换行<br>全部替换成p标签
bb = _html.split("<br />");
aa = '';
for (var i = 0; i < bb.length; i++) {
aa = aa + '<p>' + bb[i] + '</p>';
} //首行缩进
_html = aa.replace(/<p[^>]*>/ig, '<p>  ');
_html = _html.replace(/<p>  <\/p>/ig, '');
_html = _html.replace(/<p><\/p>/ig, ''); //在这里执行你将_html中的空行替换掉的操作
a.setData(_html);
}
}
}
};
})();

写到这里,就完成啦,完成了CKEditor添加一键排版插件

但是,到这里再phpcms里面,还是不能直接用的,在别的系统里面是可以的。因为phpcms的编辑器控件是需要单独选择的,还需要修改phpcms文件
 
打开phpcms/libs/classes/form.class.php
搜索['Maximize'] 在它的后面加上 ['autoformat'],就可以了。

转自:http://www.wfuyu.com/biji/25066.html

原文是程序员人生。

phpcms编辑器添加一键排版控件的更多相关文章

  1. Add an Item to the Navigation Control 将项目添加到导航控件

    In this lesson, you will learn how to add an item to the navigation control. For this purpose, the N ...

  2. 百度地图API示例之添加定位相关控件

    代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...

  3. C#构架之基础学习----动态添加窗体和 控件

    仿照窗体应用程序编写: 任务一:生成一个Form类的窗体对象frm using System.Windows.Forms;         //using指令使用Form对象创建所需的命名空间 //如 ...

  4. 在WPF中添加Windows Form控件(包括 ocx控件)

      首先,需要向项目中的reference添加两个dll,一个是.NET库中的System.Windows.Forms,另外一个是WindowsFormsIntegration,它的位置一般是在C:\ ...

  5. Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式

    Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式 摘自Unity文档 EditorGUIUtility.AddCursorRect public static void AddCursorRect ...

  6. Unity编辑器 - 使用GL绘制控件

    Unity编辑器 - 使用GL绘制控件 控件较为复杂时,可能造成界面卡顿,在EditorGUI中也可以灵活使用GL绘制来提升性能. 以绘制线段为例: using UnityEngine; using ...

  7. Unity编辑器 - DragAndDrop拖拽控件

    Unity编辑器 - DragAndDrop拖拽控件 Unity编辑器的拖拽(DragAndDrop)在网上能找到的资料少,自己稍微研究了一下,写了个相对完整的案例,效果如下 代码: object d ...

  8. IOS 当一个控件被添加到父控件中会调用(didMoveToSuperview)

    /** * 当一个控件被添加到父控件中就会调用 */ - (void)didMoveToSuperview { if (self.group.opened) { self.nameView.image ...

  9. QT5:第二章 布局排版控件

    一.简介 在QT组件面板中有Layouts和Spacers两个组件面板 注意:布局排版控件不显示 1.Layouts(布局) Vertical Layout:垂直方向布局,组件自动在垂直方向上分布 H ...

随机推荐

  1. 四大关键步骤掌握CloudOps模型

    [TechTarget中国原创] 要让IT运维向云演进,企业必须拥抱自动化,并且改变资源预配的思考方式. 新涌现的术语CloudOps——云运维的简写,指代企业如何运行以及管理基于云的系统.并且,随着 ...

  2. Win10开始菜单中的天气不更新问题的解决方法

    两台电脑同时做的Win10系统,最新的1703 Creator Update 版本,其中一台的开始菜单中天气方块总是显示图标,试了各种方法都不行,最后是点开天气App,在App的顶端有几个按钮,其中有 ...

  3. Jetty 安装、启动与项目部署

    Jetty是当下非常流行的一款轻量级Java Web服务器和Servlet容器实现,它由Eclipse基金会托管,完全免费而且开放源代码,因此所有人均可以从其官网下载最新源代码进行研究.由于其轻量.灵 ...

  4. eclipse进阶功法

    先选择要操作的行,在同时按shift+alt+a,会将所选中的文字括起来,鼠标会变成十字图标,按住鼠标左键,在相应输入文字的位置上下拖动,会出现一个竖杠,此时即可开始输入文字了,并且所选中行都有.

  5. 不作伪分享者决定完整分享我自学Python3的全部过程细节

    不作伪分享者决定完整分享我自学Python3的全部过程细节   我不要作伪分享者 十六年前我第一次见到了电脑,并深深地爱上了它: 十二年前我第一次连上了网络,并紧紧地被它爱上. 十年前的网络是田园美景 ...

  6. 洛谷P1071潜伏者(提高组)

    题目描述 R国和S国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动.历尽艰险后,潜伏于S国的R 国间谍小C终于摸清了 S 国军用密码的编码规则: 1. S国军方内部欲发送的原信息经过加密后在网 ...

  7. sharePreference的几个重点

    一.  SharePreferences是用来存储一些简单配置信息的一种机制,使用Map数据结构来存储数据,以键值对的方式存储,采用了XML格式将数据存储到设备中,文件存放在/data/data/&l ...

  8. linux perf: 为什么采样频率设置成99Hz而不是100Hz

    早晨在linuxer看到文章,感觉挺有意思,最早研究perf的时候接触过这些概念,乍一看倍感亲切. sudo perf record -F  99 -a -g --sleep 20 perf reco ...

  9. 2017 多校6 String

    多校6 String(ac自动机) 题意: 给一本有\(n\)个单词的字典 \(q\)个查询 \(pref_i,suff_i\) 查询字典里有多少单词前缀匹配\(pref_i\),后缀同时匹配\(su ...

  10. 【CZY选讲·逆序对】

    题目描述 LYK最近在研究逆序对. 这个问题是这样的. 一开始LYK有一个2^n长度的数组ai. LYK有Q次操作,每次操作都有一个参数k.表示每连续2^k长度作为一个小组.假设 n=4,k= ...