基于ThinkPHP的在线编辑器调用
开源的在线编辑器有很多,比如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的在线编辑器调用的更多相关文章
- 基于thinkphp的在线编辑器kindeditor-v4.1.3
首先,去官网下载最新版的kindeditor,然后把里面asp,jsp,net,example的全删除,然后改名为editor放进public(最外层目录的public)文件夹里面. 在目录lib目录 ...
- thinkphp——通过在线编辑器添加的内容在模板里正确显示(只显示内容,而不是html代码)
thinkphp编辑器回显问题如下: 解决办法如下: 对于编辑器发布的内容,前台模板显示为html的解决办法是: 在模板输出字段加入html_entity_decode()函数 也就是:PHP输出时的 ...
- Html在线编辑器--基于Jquery的xhEditor轻量级编辑器
xhEditor V1.2.2 下载地址 开源中国社区: http://www.oschina.net/p/xheditor xhEditor是一个基于jQuery开发的简单迷你并且高效的可视化XHT ...
- 20个最强的基于浏览器的在线代码编辑器 - OPEN资讯
20个最强的基于浏览器的在线代码编辑器 - OPEN资讯 20个最强的基于浏览器的在线代码编辑器
- 在线编辑器ACE Editor的使用
ACE 是一个开源的.独立的.基于浏览器的代码编辑器,可以嵌入到任何web页面或JavaScript应用程序中.ACE支持超过60种语言语法高亮,并能够处理代码多达400万行的大型文档.ACE开发团队 ...
- 在线编辑器CKeditor,CKfinder
在线编辑器的分类: 常见的在线编辑器有很多,比较常用的有FCKeditor(在线编辑器——Ajax 浏览器 端服务器文件管理器),CKeditor(在线编辑器与服务器端文件管理器的分离,) 其中CKe ...
- N个富文本编辑器/基于Web的HTML编辑器
转自:http://www.cnblogs.com/lingyuan/archive/2010/11/15/1877447.html 基于WEB的HTML 编辑器,WYSIWYG所见即所得的编辑器,或 ...
- 在ASP.NET Core中使用百度在线编辑器UEditor
在ASP.NET Core中使用百度在线编辑器UEditor 0x00 起因 最近需要一个在线编辑器,之前听人说过百度的UEditor不错,去官网下了一个.不过服务端只有ASP.NET版的,如果是为了 ...
- 在线编辑器的使用-KindEditor
第一种:KindEditor编辑器 步骤一:加载相应的核心的文件 下载地址:http://kindeditor.net/demo.php <link rel="stylesheet&q ...
随机推荐
- poj1703(种类并查集)
题意:有两个犯罪集团,现在有两种操作,D [a] [b]表示a和b是属于不同犯罪集团的,A [a] [b] 是询问你a和b的关系,如果ab属于同一个犯罪集团,输出In the same gang. ...
- java 泛型详解-绝对是对泛型方法讲解
Reference: http://blog.csdn.net/s10461/article/details/53941091 1. 概述 泛型在java中有很重要的地位,在面向对象编程及各种设计模 ...
- android 中解析json格式数据
本文来自http://tonysun3544.iteye.com/category/188238 package com.tony.json; import android.app.Activity; ...
- node学习笔记3——文件操作fs
文件操作关键字: http('fs') —— 请求 node 里面的 http 模块 readFile —— 读文件,参数包括 文件名,回调函数 writeFile —— 写文件,参数包括 文件 ...
- 安卓程序代写 网上程序代写[原]BluetoothSocket详解
一. BluetoothSocket简介 1. 简介 客户端与服务端 : BluetoothSocket 和 BluetoothServerSocket 类似于Java中的套接字的 Socket 和 ...
- CSS非ASCII字符最佳实践
问题场景 在写样式时经常需要用到非ASCII字符的属性值,如下: ? 1 2 3 4 5 6 7 8 9 10 11 .hot_list .sign_discount:before { cont ...
- Sword STL之仿函数概念介绍
--介绍 函数和类似函数的对象(仿函数)遍布STL.关联容器使用它们来使元素保持有序:find_if这样的算法使用它们来控制它们的行为: 如果缺少它们,那么比如for_each和transform这样 ...
- nano 命令 linux
用途说明 nano是一个字符终端的文本编辑器,有点像DOS下的editor程序.它比vi/vim要简单得多,比较适合Linux初学者使用.某些Linux发行版的默认编辑器就是nano.(nano - ...
- android 8 wifi 信号等级
wifi信号等级 /frameworks/base/wifi/java/android/net/wifi/wifimanager.java calculateSignalLevel为计算信号等级函数, ...
- git patch 使用
使用git的时候,需要删除几个id,会对到之前的代码,但又想保留现在的代码,以便后面从新合并,所以就将现在的代码打包成patch,留到下次合并. 参考链接 http://www.jianshu.com ...