├── .gitattributes ├── .gitignore ├── composer.json ├── readme.md └── src ├── Facades └── Ueditor.php ├── UeditorEndController.php ├── UeditorFrontController.php ├── UeditorServiceProivder.php ├── UeditorUploaderAbstract.php ├── Uploader.php ├── assets └── editors │ ├── demo │ └── css │ │ ├── bootstrap-theme.min.css │ │ └── bootstrap.min.css │ └── ue │ ├── dialogs │ ├── anchor │ │ └── anchor.html │ ├── attachment │ │ ├── attachment.css │ │ ├── attachment.html │ │ ├── attachment.js │ │ ├── fileTypeImages │ │ │ ├── icon_chm.gif │ │ │ ├── icon_default.png │ │ │ ├── icon_doc.gif │ │ │ ├── icon_exe.gif │ │ │ ├── icon_jpg.gif │ │ │ ├── icon_mp3.gif │ │ │ ├── icon_mv.gif │ │ │ ├── icon_pdf.gif │ │ │ ├── icon_ppt.gif │ │ │ ├── icon_psd.gif │ │ │ ├── icon_rar.gif │ │ │ ├── icon_txt.gif │ │ │ └── icon_xls.gif │ │ └── images │ │ │ ├── alignicon.gif │ │ │ ├── alignicon.png │ │ │ ├── bg.png │ │ │ ├── file-icons.gif │ │ │ ├── file-icons.png │ │ │ ├── icons.gif │ │ │ ├── icons.png │ │ │ ├── image.png │ │ │ ├── progress.png │ │ │ ├── success.gif │ │ │ └── success.png │ ├── background │ │ ├── background.css │ │ ├── background.html │ │ ├── background.js │ │ └── images │ │ │ ├── bg.png │ │ │ └── success.png │ ├── charts │ │ ├── chart.config.js │ │ ├── charts.css │ │ ├── charts.html │ │ ├── charts.js │ │ └── images │ │ │ ├── charts0.png │ │ │ ├── charts1.png │ │ │ ├── charts2.png │ │ │ ├── charts3.png │ │ │ ├── charts4.png │ │ │ └── charts5.png │ ├── emotion │ │ ├── emotion.css │ │ ├── emotion.html │ │ ├── emotion.js │ │ └── images │ │ │ ├── 0.gif │ │ │ ├── bface.gif │ │ │ ├── cface.gif │ │ │ ├── fface.gif │ │ │ ├── jxface2.gif │ │ │ ├── neweditor-tab-bg.png │ │ │ ├── tface.gif │ │ │ ├── wface.gif │ │ │ └── yface.gif │ ├── gmap │ │ └── gmap.html │ ├── help │ │ ├── help.css │ │ ├── help.html │ │ └── help.js │ ├── image │ │ ├── image.css │ │ ├── image.html │ │ ├── image.js │ │ └── images │ │ │ ├── alignicon.jpg │ │ │ ├── bg.png │ │ │ ├── icons.gif │ │ │ ├── icons.png │ │ │ ├── image.png │ │ │ ├── progress.png │ │ │ ├── success.gif │ │ │ └── success.png │ ├── insertframe │ │ └── insertframe.html │ ├── internal.js │ ├── link │ │ └── link.html │ ├── map │ │ ├── map.html │ │ └── show.html │ ├── music │ │ ├── music.css │ │ ├── music.html │ │ └── music.js │ ├── preview │ │ └── preview.html │ ├── scrawl │ │ ├── images │ │ │ ├── addimg.png │ │ │ ├── brush.png │ │ │ ├── delimg.png │ │ │ ├── delimgH.png │ │ │ ├── empty.png │ │ │ ├── emptyH.png │ │ │ ├── eraser.png │ │ │ ├── redo.png │ │ │ ├── redoH.png │ │ │ ├── scale.png │ │ │ ├── scaleH.png │ │ │ ├── size.png │ │ │ ├── undo.png │ │ │ └── undoH.png │ │ ├── scrawl.css │ │ ├── scrawl.html │ │ └── scrawl.js │ ├── searchreplace │ │ ├── searchreplace.html │ │ └── searchreplace.js │ ├── snapscreen │ │ └── snapscreen.html │ ├── spechars │ │ ├── spechars.html │ │ └── spechars.js │ ├── table │ │ ├── dragicon.png │ │ ├── edittable.css │ │ ├── edittable.html │ │ ├── edittable.js │ │ ├── edittd.html │ │ └── edittip.html │ ├── template │ │ ├── config.js │ │ ├── images │ │ │ ├── bg.gif │ │ │ ├── pre0.png │ │ │ ├── pre1.png │ │ │ ├── pre2.png │ │ │ ├── pre3.png │ │ │ └── pre4.png │ │ ├── template.css │ │ ├── template.html │ │ └── template.js │ ├── video │ │ ├── images │ │ │ ├── bg.png │ │ │ ├── center_focus.jpg │ │ │ ├── file-icons.gif │ │ │ ├── file-icons.png │ │ │ ├── icons.gif │ │ │ ├── icons.png │ │ │ ├── image.png │ │ │ ├── left_focus.jpg │ │ │ ├── none_focus.jpg │ │ │ ├── progress.png │ │ │ ├── right_focus.jpg │ │ │ ├── success.gif │ │ │ └── success.png │ │ ├── video.css │ │ ├── video.html │ │ └── video.js │ ├── webapp │ │ └── webapp.html │ └── wordimage │ │ ├── fClipboard_ueditor.swf │ │ ├── imageUploader.swf │ │ ├── tangram.js │ │ ├── wordimage.html │ │ └── wordimage.js │ ├── lang │ ├── en │ │ ├── en.js │ │ └── images │ │ │ ├── addimage.png │ │ │ ├── alldeletebtnhoverskin.png │ │ │ ├── alldeletebtnupskin.png │ │ │ ├── background.png │ │ │ ├── button.png │ │ │ ├── copy.png │ │ │ ├── deletedisable.png │ │ │ ├── deleteenable.png │ │ │ ├── listbackground.png │ │ │ ├── localimage.png │ │ │ ├── music.png │ │ │ ├── rotateleftdisable.png │ │ │ ├── rotateleftenable.png │ │ │ ├── rotaterightdisable.png │ │ │ ├── rotaterightenable.png │ │ │ └── upload.png │ └── zh-cn │ │ ├── images │ │ ├── copy.png │ │ ├── localimage.png │ │ ├── music.png │ │ └── upload.png │ │ └── zh-cn.js │ ├── themes │ ├── default │ │ ├── css │ │ │ ├── ueditor.css │ │ │ └── ueditor.min.css │ │ ├── dialogbase.css │ │ └── images │ │ │ ├── anchor.gif │ │ │ ├── arrow.png │ │ │ ├── arrow_down.png │ │ │ ├── arrow_up.png │ │ │ ├── button-bg.gif │ │ │ ├── cancelbutton.gif │ │ │ ├── charts.png │ │ │ ├── cursor_h.gif │ │ │ ├── cursor_h.png │ │ │ ├── cursor_v.gif │ │ │ ├── cursor_v.png │ │ │ ├── dialog-title-bg.png │ │ │ ├── filescan.png │ │ │ ├── highlighted.gif │ │ │ ├── icons-all.gif │ │ │ ├── icons.gif │ │ │ ├── icons.png │ │ │ ├── loaderror.png │ │ │ ├── loading.gif │ │ │ ├── lock.gif │ │ │ ├── neweditor-tab-bg.png │ │ │ ├── pagebreak.gif │ │ │ ├── scale.png │ │ │ ├── sortable.png │ │ │ ├── spacer.gif │ │ │ ├── sparator_v.png │ │ │ ├── table-cell-align.png │ │ │ ├── tangram-colorpicker.png │ │ │ ├── toolbar_bg.png │ │ │ ├── unhighlighted.gif │ │ │ ├── upload.png │ │ │ ├── videologo.gif │ │ │ ├── word.gif │ │ │ └── wordpaste.png │ └── iframe.css │ ├── third-party │ ├── SyntaxHighlighter │ │ ├── shCore.js │ │ └── shCoreDefault.css │ ├── codemirror │ │ ├── codemirror.css │ │ └── codemirror.js │ ├── highcharts │ │ ├── adapters │ │ │ ├── mootools-adapter.js │ │ │ ├── mootools-adapter.src.js │ │ │ ├── prototype-adapter.js │ │ │ ├── prototype-adapter.src.js │ │ │ ├── standalone-framework.js │ │ │ └── standalone-framework.src.js │ │ ├── highcharts-more.js │ │ ├── highcharts-more.src.js │ │ ├── highcharts.js │ │ ├── highcharts.src.js │ │ ├── modules │ │ │ ├── annotations.js │ │ │ ├── annotations.src.js │ │ │ ├── canvas-tools.js │ │ │ ├── canvas-tools.src.js │ │ │ ├── data.js │ │ │ ├── data.src.js │ │ │ ├── drilldown.js │ │ │ ├── drilldown.src.js │ │ │ ├── exporting.js │ │ │ ├── exporting.src.js │ │ │ ├── funnel.js │ │ │ ├── funnel.src.js │ │ │ ├── heatmap.js │ │ │ ├── heatmap.src.js │ │ │ ├── map.js │ │ │ ├── map.src.js │ │ │ ├── no-data-to-display.js │ │ │ └── no-data-to-display.src.js │ │ └── themes │ │ │ ├── dark-blue.js │ │ │ ├── dark-green.js │ │ │ ├── gray.js │ │ │ ├── grid.js │ │ │ └── skies.js │ ├── jquery-1.10.2.js │ ├── jquery-1.10.2.min.js │ ├── jquery-1.10.2.min.map │ ├── video-js │ │ ├── font │ │ │ ├── vjs.eot │ │ │ ├── vjs.svg │ │ │ ├── vjs.ttf │ │ │ └── vjs.woff │ │ ├── video-js.css │ │ ├── video-js.min.css │ │ ├── video-js.swf │ │ ├── video.dev.js │ │ └── video.js │ ├── webuploader │ │ ├── Uploader.swf │ │ ├── webuploader.css │ │ ├── webuploader.custom.js │ │ ├── webuploader.custom.min.js │ │ ├── webuploader.flashonly.js │ │ ├── webuploader.flashonly.min.js │ │ ├── webuploader.html5only.js │ │ ├── webuploader.html5only.min.js │ │ ├── webuploader.js │ │ ├── webuploader.min.js │ │ ├── webuploader.withoutimage.js │ │ └── webuploader.withoutimage.min.js │ └── zeroclipboard │ │ ├── ZeroClipboard.js │ │ ├── ZeroClipboard.min.js │ │ └── ZeroClipboard.swf │ ├── ueditor.all.min.js │ ├── ueditor.config.js │ └── ueditor.parse.min.js ├── config └── zhangmazi │ ├── ext2mime.php │ ├── filesystems.php │ └── ueditor.php └── views ├── ueditor.blade.php └── ueditorDemoIndex.blade.php /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=php 2 | *.css linguist-language=php 3 | *.html linguist-language=php -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zhangmazi/laravel-ueditor", 3 | "description": "百度编辑器For Laravel 5", 4 | "homepage": "http://www.ninja911.com", 5 | "keywords": ["百度", "baidu", "laravel", "editor", "ueditor"], 6 | "require": { 7 | "laravel/framework": "^5.0" 8 | }, 9 | "require-dev": { 10 | "phpunit/phpunit": "3.*", 11 | "mockery/mockery": "~0.9.2" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Zhang Ma Zi", 17 | "email": "ninja911.com@gmail.com", 18 | "homepage": "http://www.ninja911.com/" 19 | } 20 | ], 21 | "autoload": { 22 | "psr-4": { 23 | "Zhangmazi\\Ueditor\\": "src/" 24 | } 25 | }, 26 | "extra": { 27 | "branch-alias": { 28 | "dev-master": "1.0-dev" 29 | } 30 | }, 31 | "minimum-stability": "stable", 32 | "prefer-stable": true 33 | } 34 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # 百度编辑器 For Laravel 5 3 | 4 | 支持自定义路由,支持图片、附件上传, 默认前后台独立控制器,支持重写方法方便自己的业务逻辑处理,支持扩展图片助手(推荐使用Intervention\Image第三方包) 5 | 6 | 7 | ## 官网 8 | 9 | [NinJa911工作室](http://www.ninja911.com). 10 | 11 | ## 疑问讨论 12 | 13 | 请在issue里new一个. 14 | 15 | ## 其他源 16 | 17 | [国外 github.com](https://github.com/zhangmazi/laravel-ueditor) 18 | [国内 coding.net](https://coding.net/u/ninja911/p/laravel-ueditor) 19 | 20 | 21 | ## 授权 22 | 23 | 此Laravel 扩展包基于MIT协议开源[MIT license](http://opensource.org/licenses/MIT). 24 | 25 | 26 | # 安装 27 | 28 | #### 1.Composer 安装 29 | 30 | ```shell 31 | composer require "zhangmazi/laravel-ueditor" 32 | ``` 33 | 34 | #### 2.编辑config/app.php文件,在节点[providers]中加入 35 | 36 | ```php 37 | Zhangmazi\Ueditor\UeditorServiceProivder::class 38 | ``` 39 | 40 | #### 3.在命令行工具执行 41 | 42 | ```shell 43 | php artisan vendor:publish --provider="Zhangmazi\Ueditor\UeditorServiceProivder" 44 | ``` 45 | 46 | 相关资源配置会成功发布到:config/zhangmazi/(配置); public/assets/(静态资源); resources/views/vendor/zhangmazi/(视图,包含demo所需). 47 | 48 | ### 配置 49 | 50 | #### 1.配置config/zhangmazi/filesystem.php 51 | 52 | 请根据注释填写,特别要注意root和url_root,这个2个很关键,因为直接导致你是否能上传成功和是否能正常开放预览附件; root的物理路径一定有0755或者0777(当需要建立子目录时)权限. 53 | [version 1.0.5]这次更新主要是配置调整,所以重要操作,请将disks节点数组复制到config/filesystem.php内的disks内,并注意如果启用S3驱动,root一定要是null 54 | 55 | #### 2.配置config/zhangmazi/ueditor.php 56 | 57 | 请根据注释填写,节点[routes]支持多组应用场景,其配置其实就Laravel的Route原生配置方法; 其中带有"group_"前缀的都不填,将不使用路由组模式; 如果"via_integrate"为true,将使用内置命名空间,同时不要修改"uses". 58 | 59 | #### 3.配置config/zhangmazi/ext2mime.php 60 | 61 | 这个增加上传安全性的, 如果您觉得多了和少了, 请自行根据格式进行修改. 62 | 63 | # 使用 64 | 65 | ### Demo使用 66 | 67 | 开发此包时, 为了增加体验感, 特为大家准备了demo. 启用内置服务运行命令 68 | 69 | ```shell 70 | php artisan serve --host=0.0.0.0 --port=8030 71 | ``` 72 | 73 | 访问 [http://localhost:8030/zhangmazi/ueditor/demo/index](http://localhost:8030/zhangmazi/ueditor/demo/index), 其中localhost跟更改为你自己的绑定的域名. 74 | 75 | 为了安全性, 在[.env]文件中APP_DEBUG=true才能使用demo,否则无法访问以上demo相关路由地址. 76 | 77 | 78 | ### 如何使用 79 | 80 | #### 1.在您的视图中, 在body闭包前(即`
15 |`),加入以下代码 81 | 82 | ```html 83 | @include("zhangmazi::ueditor") 84 | ``` 85 | 86 | #### 2.在您的视图中, 需要占位编辑器的dom节点内,加入以下代码 87 | 88 | ```html 89 | 90 | ``` 91 | 92 | 其中id="ueditor_filed"这里是需要给百度编辑器创建的时候用到的名字, 如果同一个页面有多个,这个id请用不同的名字替换. 93 | 94 | #### 3.在您的视图中, 在body闭包前(即``),加入以下代码 95 | 96 | ```html 97 | 102 | ``` 103 | 104 | 如果需要更多参考以及调用样板,比如如何自定义编辑工具栏、同一个页面多个编辑器,请查看阅读文件 vendor/zhangmazi/ueditor/src/views/ueditorDemoIndex.blade.php 105 | 106 | 107 | # 自定义扩展 108 | 109 | 以下说明需要一定PHP知识和Laravel5框架了解背景 110 | 111 | ### 1.扩展控制器 112 | 113 | 新建一个控制器, 内部复用一个类UeditorUploaderAbstract,有兴趣可以查看这个类,根据自身业务选择性重写覆盖. 114 | 115 | ```php 116 | 122 | * @date 2016-08-20 22:22 123 | */ 124 | namespace App\Http\Controllers; 125 | 126 | use App\Http\Controllers\Controller; 127 | use Zhangmazi\Ueditor\UeditorUploaderAbstract; 128 | 129 | class CustomUeditorController extends Controller 130 | { 131 | use UeditorUploaderAbstract; 132 | /** 133 | * 记录上传日志(这些方法都可以重写覆盖) 134 | * @return mixed 135 | */ 136 | protected function insertRecord() 137 | { 138 | 139 | } 140 | 141 | /** 142 | * 验证是否合法(这些方法都可以重写覆盖) 143 | * @return bool|mixed 144 | */ 145 | protected function checkGuard() 146 | { 147 | //如果是后端 148 | //return Auth::check(); 149 | return true; 150 | } 151 | 152 | /** 153 | * 获取相对于public_path()根目录的相对目录 154 | * @return bool|mixed 155 | */ 156 | protected function getRelativeDir() 157 | { 158 | return 'uploads/ueditor'; 159 | } 160 | 161 | /** 162 | * 获取保存根目录路径 163 | * @paraam string $driver_name 驱动名 164 | * @return string 165 | */ 166 | protected function getSaveRootPath($driver_name = 'local') 167 | { 168 | return storage_path('app/ueditor'); 169 | } 170 | 171 | /** 172 | * 删除原始文件 173 | * @param $file 174 | * @return bool 175 | */ 176 | protected function deleteOriginFile($file) 177 | { 178 | File::delete($file['file_native_path']); 179 | File::delete($file['origin_pic_native_path']); 180 | 181 | return true; 182 | } 183 | } 184 | 185 | ?> 186 | ``` 187 | 188 | ### 2.配置config/zhangmazi/ueditor.php 189 | 190 | 把相关路由配置一下,不用内置的 191 | 192 | ### 3.查看路由清单,看是否生效,命令行里执行 193 | 194 | ```shell 195 | php artisan route:list 196 | ``` 197 | 198 | # TODO 199 | 200 | 201 | ### 1.完成i18n语言包中的中文和英文 202 | 203 | 目前个人时间比较紧,如果谁有愿意翻译修改支持i18n,大大的感谢,请提交github merge request 204 | 205 | ### 2.发现或者支持更多的Storage第三方文件存储驱动 206 | 207 | 目前Laravel对亚马逊S3支持的相对完美, 但像其他国内的云存储服务,需要用Storage::extend来扩展驱动以及配置 208 | -------------------------------------------------------------------------------- /src/Facades/Ueditor.php: -------------------------------------------------------------------------------- 1 | 6 | * @date 2016-08-20 22:32 7 | */ 8 | namespace Zhangmazi\Ueditor\Facades; 9 | 10 | use Illuminate\Support\Facades\Facade; 11 | 12 | class Ueditor extends Facade 13 | { 14 | protected static function getFacadeAccessor() 15 | { 16 | return 'ueditor'; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/UeditorEndController.php: -------------------------------------------------------------------------------- 1 | 6 | * @date 2016-08-20 22:22 7 | */ 8 | namespace Zhangmazi\Ueditor; 9 | 10 | use Illuminate\Routing\Controller; 11 | use Illuminate\Http\Request; 12 | use Illuminate\Support\Facades\Cookie; 13 | 14 | class UeditorEndController extends Controller 15 | { 16 | use UeditorUploaderAbstract; 17 | protected $cookieName = 'zmz'; 18 | 19 | public function demoIndex() 20 | { 21 | $is_logined = $this->checkGuard(); 22 | return view('zhangmazi::ueditorDemoIndex', ['is_logined' => $is_logined]); 23 | } 24 | 25 | /** 26 | * 登录 27 | * @param Request $request 28 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View 29 | */ 30 | public function demoLogin(Request $request) 31 | { 32 | $account = $request->input('account', ''); 33 | $password = $request->input('password', ''); 34 | if ($account == 'zhangmazi' && $password == '88888888') { 35 | return redirect(route('zhangmazi_udemo_index'))->cookie($this->setLogined($account)); 36 | } else { 37 | return abort(500, '登录失败'); 38 | } 39 | } 40 | 41 | /** 42 | * 退出登录 43 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector 44 | */ 45 | public function demoLogout() 46 | { 47 | return redirect(route('zhangmazi_udemo_index'))->cookie($this->unsetLogined()); 48 | } 49 | 50 | /** 51 | * 重写验证 52 | * @return bool 53 | */ 54 | protected function checkGuard() 55 | { 56 | $cookie = Cookie::get($this->cookieName); 57 | return $cookie == 'zhangmazi'; 58 | } 59 | 60 | 61 | /** 62 | * 设置登录状态 63 | * @param $account 64 | * @return mixed 65 | */ 66 | private function setLogined($account) 67 | { 68 | return Cookie::make($this->cookieName, $account); 69 | } 70 | 71 | /** 72 | * 设置退出状态 73 | * @return mixed 74 | */ 75 | private function unsetLogined() 76 | { 77 | return Cookie::forget($this->cookieName); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/UeditorFrontController.php: -------------------------------------------------------------------------------- 1 | 6 | * @date 2016-08-20 22:22 7 | */ 8 | namespace Zhangmazi\Ueditor; 9 | 10 | use Illuminate\Routing\Controller; 11 | use Illuminate\Http\Request; 12 | use Illuminate\Support\Facades\Session; 13 | use Illuminate\Support\Facades\Cookie; 14 | 15 | class UeditorFrontController extends Controller 16 | { 17 | use UeditorUploaderAbstract; 18 | protected $cookieName = 'zmz'; 19 | 20 | /** 21 | * Demo首页 22 | * @param Request $request 23 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View 24 | */ 25 | public function demoIndex(Request $request) 26 | { 27 | Session::start(); 28 | $is_logined = $this->checkLogined(); 29 | return view('zhangmazi::ueditorDemoIndex', ['is_logined' => $is_logined]); 30 | } 31 | 32 | /** 33 | * 重写验证 34 | * @return bool 35 | */ 36 | protected function checkLogined() 37 | { 38 | $cookie = Cookie::get($this->cookieName); 39 | return $cookie == 'zhangmazi'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/assets/editors/ue/dialogs/anchor/anchor.html: -------------------------------------------------------------------------------- 1 | 3 | 4 |
5 | 6 |
7 | 13 | 14 |
40 |