phpcms编辑器添加一键排版控件
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(/ /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编辑器添加一键排版控件的更多相关文章
- 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 ...
- 百度地图API示例之添加定位相关控件
代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...
- C#构架之基础学习----动态添加窗体和 控件
仿照窗体应用程序编写: 任务一:生成一个Form类的窗体对象frm using System.Windows.Forms; //using指令使用Form对象创建所需的命名空间 //如 ...
- 在WPF中添加Windows Form控件(包括 ocx控件)
首先,需要向项目中的reference添加两个dll,一个是.NET库中的System.Windows.Forms,另外一个是WindowsFormsIntegration,它的位置一般是在C:\ ...
- Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式
Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式 摘自Unity文档 EditorGUIUtility.AddCursorRect public static void AddCursorRect ...
- Unity编辑器 - 使用GL绘制控件
Unity编辑器 - 使用GL绘制控件 控件较为复杂时,可能造成界面卡顿,在EditorGUI中也可以灵活使用GL绘制来提升性能. 以绘制线段为例: using UnityEngine; using ...
- Unity编辑器 - DragAndDrop拖拽控件
Unity编辑器 - DragAndDrop拖拽控件 Unity编辑器的拖拽(DragAndDrop)在网上能找到的资料少,自己稍微研究了一下,写了个相对完整的案例,效果如下 代码: object d ...
- IOS 当一个控件被添加到父控件中会调用(didMoveToSuperview)
/** * 当一个控件被添加到父控件中就会调用 */ - (void)didMoveToSuperview { if (self.group.opened) { self.nameView.image ...
- QT5:第二章 布局排版控件
一.简介 在QT组件面板中有Layouts和Spacers两个组件面板 注意:布局排版控件不显示 1.Layouts(布局) Vertical Layout:垂直方向布局,组件自动在垂直方向上分布 H ...
随机推荐
- 内存压缩PK页面交换 解决内存问题谁更在行
一台服务器能够支持的虚拟机数量通常取决于物理硬件所能够提供的可用计算资源.大多数资源, 比如处理器周期.存储I/O和网络带宽等,都能够相对简单地进行共享.这种做法的原理在于负载并不总是处于忙碌状态,因 ...
- .swp文件的恢复
.swp 编辑文件的过程中会出现这个隐藏文件. 文件如果正常保存,.swp就会自动删除.如果不正常退出,比如关机,.swp就会留下来. linux下: ls -all 可以查看隐藏文件 命令: vi ...
- python负数除法与模运算
1.负数除法: >>> print 45/76>>> print -45/7-7 >>> print 45/-7-7 >>> p ...
- 聊聊、AES 和 DES
AES 和 DES 都是对称加密的一种,但是 DES 的 Key 是 56 位,而 AES 的 Key 有 128,256,512 可选. AES 加密AES String randomKey = & ...
- HDU 3775 Chain Code pick定理
pick定理:一个计算点阵中顶点在格点上的多边形面积公式:S=a+b÷2-1,其中a表示多边形内部的点数,b表示多边形边界上的点数,s表示多边形的面积. 思路:http://blog.csdn.net ...
- vmware设置静态ip(复制)
一.安装好虚拟后在菜单栏选择编辑→ 虚拟网络编辑器,打开虚拟网络编辑器对话框,选择Vmnet8 Net网络连接方式,随意设置子网IP,点击NAT设置页面,查看子网掩码和网关,后面修改静态IP会用到. ...
- android ViewGroup getChildDrawingOrder与 isChildrenDrawingOrderEnabled()
getChildDrawingOrder与 isChildrenDrawingOrderEnabled()是属于ViewGroup的方法. getChildDrawingOrder 用于 返回当前 ...
- Java 多线程(Thread)学习
多线程:就是进程的扩展,实现并发.一个进程可以包含多个线程,进程一般是由操作系统控制,而线程就是由程序员控制的,所以作为编程人员做好线程是我们的重点. 线程和进程一样分为五个阶段:创建.就绪.运行.阻 ...
- ajax-高设3
ajax 1.XHR Ajax 技术的核心是 XMLHttpRequest 对象(简称 XHR),这是由微软首先引入的一个特性,其他浏览器提供商后来都提供了相同的实现.在 XHR 出现之前,Ajax ...
- 防御暴力破解SSH攻击
托管在IDC的机器我们通常都用SSH方式来远程管理.但是经常可以发现log-watch的日志中有大量试探登录的 信息,为了我们的主机安全,有必要想个方法来阻挡这些可恨的"HACKER&quo ...