博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ThinkPHP整合各大主流在线编辑器的方法
阅读量:6989 次
发布时间:2019-06-27

本文共 3218 字,大约阅读时间需要 10 分钟。

   今天一个客户要求在编辑器里增加可以拖动图片的方法,研究了很久,发现这几种编辑器只有在ie下才可以拖动图片大小,包括网易用的编辑器,QQ空间的编辑器,先提前声明一下。下面进入重点

   1.百度编辑器ueditor

   先新建项目,生成以后在目录下新建一个plugins文件夹

   然后下载ueditor,地址:,注意编码。下载以后解压将整合文件夹放到plugins里,并且改名为ueditor

   将项目名/Lib/Action/IndexAction.clas.php添加

1
2
3
4
5
class 
IndexAction 
extends 
Action {
    
function 
index(){
        
$
this
->display();
    
}
}

然后在对应的模版里添加,在<head></head>中间添加

1
2
<
script 
type
=
"text/javascript" 
src
=
"/edit/plugins/ueditor/ueditor.config.js"
></
script
>
<
script 
type
=
"text/javascript" 
src
=
"/edit/plugins/ueditor/ueditor.all.js"
></
script
>

在需要的地方添加

1
2
3
4
5
<
textarea 
id
=
"myEditor" 
name
=
"content" 
style
=
"width:700px;height:300px;"
>
</
textarea
>
<
script 
type
=
"text/javascript"
>
    
UE.getEditor('myEditor')
</
script
>

这是textera的方式,也可以用div,p都可以,官方推荐的是

1
2
3
<
script 
type
=
"text/plain" 
id
=
"myEditor"
>
    
//从数据库中取出文章内容打印到此处
</
script
>

1
2
3
4
5
6
7
8
9
10
11
12
13
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'
'|'
,
                
'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'
'|'
,
                
'print'
'preview'
'searchreplace'
'help'
]
        
]

看需要删除即可。

最近百度网盘有个活动,如果有兴趣的朋友可以参加一下,还有个人收集的一些书籍

http://pan.baidu.com/share/link?shareid=3950160737&uk=3826886292

2.kindeditor

下载地址:

解压改名放到plugins下,

在模版里添加

1
2
3
4
5
6
<
script 
charset
=
"utf-8" 
src
=
"/edit/plugins/kindeditor/kindeditor.js"
></
script
>
<
script 
charset
=
"utf-8" 
src
=
"/edit/plugins/kindeditor/lang/ko.js"
></
script
>
<
script
>
        
KindEditor.ready(function(K) {
                
window.editor = K.create('#editor_id');
        
});
1
2
<
textarea 
id
=
"myEditor" 
name
=
"content" 
style
=
"width:700px;height:300px;"
>
</
textarea
>

显示的样式,自然就是51cto博客编辑器的样子了。

3.xheditor  ,号称最干净整洁的在线编辑器

下载地址:

复制到plugins下改名

在需要的模版中添加

1
2
<
script 
type
=
"text/javascript" 
src
=
"/edit/plugins/xheditor/jquery/jquery-1.4.4.min.js"
></
script
>
<
script 
type
=
"text/javascript" 
src
=
"/edit/plugins/xheditor/xheditor-1.1.14-zh-cn.js"
></
script
>
1
<
textarea 
name
=
"content" 
class
=
"xheditor"
></
textarea
>

即可,剩下的就是和后端的处理了。

   一般我就比较喜欢使用这三种编辑器,而且各有特点,现在不喜欢fckeditor了,外观不美观,而且上传之类的,容易出问题,包括有上传漏洞。就不说了。

本文转自 3147972 51CTO博客,原文链接:http://blog.51cto.com/a3147972/1243384,如需转载请自行联系原作者
你可能感兴趣的文章
离线情报分析工具CaseFile
查看>>
【iCore4 双核心板_FPGA】例程九:锁相环实验——锁相环使用
查看>>
05Hadoop-左外连接
查看>>
python3 识别图片文字
查看>>
文字在div中水平和垂直居中的的css样式
查看>>
cocos creator protobuf实践
查看>>
精品素材:推荐15套非常漂亮的 iOS 图标素材
查看>>
使用HttpSessionListener接口监听Session的创建和失效
查看>>
android 国际化
查看>>
10000单词积累,从今天开始(待续)。。。
查看>>
转Spring+Hibernate+EHcache配置(三)
查看>>
使用现有ECC数据库进行安装或者恢复系统
查看>>
发布我的高性能纯C#图像处理基本类,顺便也挑战一下极限。:)
查看>>
在Ubuntu上单机安装Hadoop
查看>>
安装SharePoint2010出现“Could not find stored procedure ‘sp_dboption’.”的解决方法
查看>>
存储过程中执行动态Sql语句
查看>>
SQL Server里简单参数化的痛苦
查看>>
《逻辑与计算机设计基础(原书第5版)》——1.9 习题
查看>>
停止去人性化吧 SOC应找回人的元素
查看>>
数据中心托管节约企业成本
查看>>