开源的在线编辑器有很多,比如FCKEditor,UEditor,Kindeditor等,调用方式也都大同小异

下面列举UEditor在线编辑器插件在ThinkPHP里面的应用

1、Ueditor下载地址:http://ueditor.baidu.com/website/download.html(注意编码)

2、使用ThinkPHP版本为ThinkPHP3.1.2

先下载Ueditor插件解压放置ThinkPHP项目的根目录并将文件夹名称重命名为ueditor

如下图:

编写测试类:

 class IndexAction extends Action {
public function index(){
$this->display();
}

对应映射Html静态页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Ueditor</title>
<script type="text/javascript" src="__ROOT__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__ROOT__/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
function edit(){
UE.getEditor('content');
}
</script> </head>
<body onload="edit()">
<form action="__URL__/edit" method="post">
标题:<br/>
<input type="text" name="info"/><br/>
内容:<textarea id="content" name="content" style="width:700px;height:300px;"></textarea>
<input type="submit" value="提交"/>
</form>
</body>
</html>

在静态页面HTML用Javascript调用,分别引入ueditor.config.js、ueditor.all.js两个JS文件,可直接用UE.getEditor(参数1,{参数2});进行调用

参数1:

需要和下面的TextArea的ID名对应。

参数2:(非必须)

一些初始化参数,比如宽度,高度,各种按钮,样式等。

若不填写此参数,默认下是用TextArea的Style样式的宽高来定义Ueditor

效果如下图:

提交表单:

-------------------------------------------------------------华丽的分割线-------------------------------------------------------------------

来说下关于参数二,毕竟一般的在线编辑器是不需要那么多功能的,使其简洁。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Ueditor</title>
<script type="text/javascript" src="__ROOT__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__ROOT__/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
function edit(){
UE.getEditor('content',{
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
toolbars:[['FullScreen', 'Source', 'Undo', 'Redo','bold','test']],
//focus时自动清空初始化时的内容
autoClearinitialContent:true,
//关闭字数统计
wordCount:false,
//关闭elementPath
elementPathEnabled:false,
//默认的编辑区域高度
initialFrameHeight:300
//更多其他参数,请参考ueditor.config.js中的配置项
});
}
</script> </head>
<body onload="edit()">
<form action="__URL__/edit" method="post">
标题:<br/>
<input type="text" name="info"/><br/>
内容:<textarea id="content" name="content" style="width:700px;height:300px;"></textarea>
<input type="submit" value="提交"/>
</form>
</body>
</html>

关于参数二的toolbars在开发文档ueditor.config.js中有给出:

toolbars: [[
'fullscreen', 'source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
'directionalityltr', 'directionalityrtl', 'indent', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
'print', 'preview', 'searchreplace', 'help', 'drafts'
]]

按照个人需求填写所需就成

上图代码效果图:

  

基于ThinkPHP的在线编辑器调用的更多相关文章

  1. 基于thinkphp的在线编辑器kindeditor-v4.1.3

    首先,去官网下载最新版的kindeditor,然后把里面asp,jsp,net,example的全删除,然后改名为editor放进public(最外层目录的public)文件夹里面. 在目录lib目录 ...

  2. thinkphp——通过在线编辑器添加的内容在模板里正确显示(只显示内容,而不是html代码)

    thinkphp编辑器回显问题如下: 解决办法如下: 对于编辑器发布的内容,前台模板显示为html的解决办法是: 在模板输出字段加入html_entity_decode()函数 也就是:PHP输出时的 ...

  3. Html在线编辑器--基于Jquery的xhEditor轻量级编辑器

    xhEditor V1.2.2 下载地址 开源中国社区: http://www.oschina.net/p/xheditor xhEditor是一个基于jQuery开发的简单迷你并且高效的可视化XHT ...

  4. 20个最强的基于浏览器的在线代码编辑器 - OPEN资讯

    20个最强的基于浏览器的在线代码编辑器 - OPEN资讯 20个最强的基于浏览器的在线代码编辑器

  5. 在线编辑器ACE Editor的使用

    ACE 是一个开源的.独立的.基于浏览器的代码编辑器,可以嵌入到任何web页面或JavaScript应用程序中.ACE支持超过60种语言语法高亮,并能够处理代码多达400万行的大型文档.ACE开发团队 ...

  6. 在线编辑器CKeditor,CKfinder

    在线编辑器的分类: 常见的在线编辑器有很多,比较常用的有FCKeditor(在线编辑器——Ajax 浏览器 端服务器文件管理器),CKeditor(在线编辑器与服务器端文件管理器的分离,) 其中CKe ...

  7. N个富文本编辑器/基于Web的HTML编辑器

    转自:http://www.cnblogs.com/lingyuan/archive/2010/11/15/1877447.html 基于WEB的HTML 编辑器,WYSIWYG所见即所得的编辑器,或 ...

  8. 在ASP.NET Core中使用百度在线编辑器UEditor

    在ASP.NET Core中使用百度在线编辑器UEditor 0x00 起因 最近需要一个在线编辑器,之前听人说过百度的UEditor不错,去官网下了一个.不过服务端只有ASP.NET版的,如果是为了 ...

  9. 在线编辑器的使用-KindEditor

    第一种:KindEditor编辑器 步骤一:加载相应的核心的文件 下载地址:http://kindeditor.net/demo.php <link rel="stylesheet&q ...

随机推荐

  1. kylin的状态栏(启动器)改成ubuntu之前的样子

    ylin的状态栏(启动器)改成ubuntu之前的样子,ubuntu是在左边的,kylin在底部.占空间. 执行命令 gsettings set com.canonical.Unity.Launcher ...

  2. 微服务之springCloud和docker-provide(二)

    简介 通过上一节我们已经通过docker-compose在swarm中部署了有三个实例的高可用eureka服务注册中心,本节我们讨论一下,怎么在创建一个spring cloud生产者,并用docker ...

  3. 用B表更新A表

    UPDATE dbo.POR_LOT SET POR_LOT.SHIPPED_FLAG =B.SHIPPED_FLAGFROM POR_LOT A INNER JOIN ( SELECT T5.LOT ...

  4. C#使用ActiveMQ实例

    1. ActiveMQ消息总线简介 消息队列(Message Queue,简称MQ),从字面意思上看,本质是个队列,FIFO先入先出,只不过队列中存放的内容是message而已.主要用作不同进程.应用 ...

  5. Android——音乐播放器完善——进度条显示当前播放进度,加可拖动进度条(未待解决完问题)

    效果: 问题:可拖动进度条随进度条移动时,会致使音乐卡顿(待解决) xml <?xml version="1.0" encoding="utf-8"?&g ...

  6. jpegtran图片压缩工具

    首先下载  jpegtran  下载地址为  http://jpegclub.org/jpegtran.exe jpegtran -copy none -optimize -perfect aa.jp ...

  7. WinForm 控件键盘消息处理剖析(转)

    一直想整理键盘事件的调用顺序,刚好看见园子里的这篇文章,写的不错,就转载了:http://www.cnblogs.com/tedzhao/archive/2010/09/07/1820557.html ...

  8. Extjs js 产生Guid或者UUID

    Ext.data.IdGenerator.get('uuid').generate() 结果:a9c4efb8-06c9-4c2e-8a70-bb36a69e053e 更多介绍:http://docs ...

  9. Android安装后没有完成和打开按钮

    File apkFile = new File(filePath); Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVIT ...

  10. Java设计模式(5)共享模式/享元模式(Flyweight模式)

    Flyweight定义:避免大量拥有相同内容的小类的开销(如耗费内存),使大家共享一个类(元类). 为什么使用共享模式/享元模式 面向对象语言的原则就是一切都是对象,但是如果真正使用起来,有时对象数可 ...