• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP如何搭建百度Ueditor富文本编辑器 - 头大的冯冯

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

PHP如何搭建百度Ueditor富文本编辑器

文章正文

官网:https://ueditor.baidu.com/website/download.html

将下载好的文件解压到thinkphp项目中,本文是解压到PUBLIC目录下并改文件夹名称为ueditor

第一步 引入javascript

在html中如入下面的js语句引入相关文件

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"></script>

第二步 添加textare文本域并设置id值

<textarea type="text" name="content" id="EditorId" placeholder="请输入内容"></textarea>

第三步 初始化UEditor编辑器

在html代码中添加下面的代码初始化UEditor编译器

<script type="text/javascript" charset="utf-8">//初始化编辑器 
   window.UEDITOR_HOME_URL = "__PUBLIC__/ueditor/";//配置路径设定为UEditor所放的位置 
   window.onload=function(){ 
    window.UEDITOR_CONFIG.initialFrameHeight=600;//编辑器的高度 
    window.UEDITOR_CONFIG.initialFrameWidth=1200;//编辑器的宽度 
    var editor = new UE.ui.Editor({ 
      imageUrl : \'\', 
      fileUrl : \'\', 
      imagePath : \'\', 
      filePath : \'\', 
      imageManagerUrl:\'\', //图片在线管理的处理地址 
      imageManagerPath:\'__ROOT__/\'
    }); 
    editor.render("EditorId");//此处的EditorId与<textarea name="content" id="EditorId">的id值对应 </textarea> 
  } 
</script>

第四步 设置图片上传路径

UEditor编辑器的默认图片上传路径是根目录下/ueditor/php/upload/image/目录,没有这个目录会自动创建,如果要自定义图片上传路径,可以在ueditor/php/config.json文件中12行处修改。

最后贴上完整的html代码:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
  <meta charset="UTF-8"> 
  <title>Document</title> 
  <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.js"></script> 
</head> 
<body> 

 <form action="__URL__/receiver" method="post" accept-charset="utf-8"> 
  <textarea type="text" name="content" id="EditorId" placeholder="请输入内容"></textarea> 
  <input type="submit" value="提交"> 
 </form> 

  <script type="text/javascript" charset="utf-8">//初始化编辑器 
  window.UEDITOR_HOME_URL = "__PUBLIC__/ueditor/";//配置路径设定为UEditor所放的位置 
  window.onload=function(){ 
    window.UEDITOR_CONFIG.initialFrameHeight=600;//编辑器的高度 
    window.UEDITOR_CONFIG.initialFrameWidth=1200;//编辑器的宽度 
    var editor = new UE.ui.Editor({ 
      imageUrl : \'\', 
      fileUrl : \'\', 
      imagePath : \'\', 
      filePath : \'\', 
      imageManagerUrl:\'\', //图片在线管理的处理地址 
      imageManagerPath:\'__ROOT__/\' 
    }); 
    editor.render("EditorId");//此处的EditorId与<textarea name="content" id="EditorId">的id值对应 </textarea> 
  } 
</script> 
</body> 
</html>

效果图

 

转载:https://mp.weixin.qq.com/s/3gUI20ZP1guTnrJgMBoIPw


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
php 富文本编辑器 tp5发布时间:2022-07-10
下一篇:
php去除富文本编辑器中的内容格式发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap