maxiao64 / simditor
Simditor for Laravel-admin
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 5
Language:JavaScript
Requires
- php: >=7.0.0
- encore/laravel-admin: ~1.6
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-04-15 11:38:28 UTC
README
This is a laravel-admin
extension that integrates Simditor for qiniu upload image function into the laravel-admin
form.
Screenshot
Installation
composer require MaXiao/simditor php artisan vendor:publish --tag=laravel-admin-simditor
Configuration
In the extensions
section of the config/admin.php
file, add some configuration that belongs to this extension.
'extensions' => [ 'simditor' => [ // Set to false if you want to disable this extension 'enable' => true, // Editor configuration 'config' => [ 'upload' => [ 'qnTokenUrl' => '/' . env('ADMIN_ROUTE_PREFIX') . '/api/getQnToken', // 获取七牛配置项的接口 'fileKey' => 'upload_file', 'connectionCount' => 3, 'leaveConfirm' => 'Uploading is in progress, are you sure to leave this page?' ], 'tabIndent' => true, 'toolbar' => ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment'], 'toolbarFloat' => true, 'toolbarFloatOffset' => 0, 'toolbarHidden' => false, 'pasteImage' => true, 'cleanPaste' => false, ] ] ]
qnTokenUrl 接口的格式 请求方式 GET, 返回格式
{ "uphost": "https://up-z2.qiniup.com", // 图片上传的地址 "domain": "http://image.mmmx17.cn", // 七牛的域名 "uptoken": "xxxxxxxxx" // 上传图片需要的token }
接口示例:
// in controller public function getQnToken() { $qnConfig = new Config(); $qnConfig->useHTTPS = env('IS_HTTPS_APP'); list($uphost, $error) = $qnConfig->getUpHostV2(config('filesystems.disks.qiniu.access_key') , config('filesystems.disks.qiniu.bucket')); if($error) { return []; } return [ 'uphost' => $uphost, 'domain' => config('filesystem.disks.qiniu.domains.default'), 'uptoken' => Storage::disk('qiniu')->getAdapter()->uploadToken() ]; } // in config/filesystems.php ... 'qiniu' => [ 'driver' => 'qiniu', 'domains' => [ 'default' => 'http://image.mmmx17.cn', //你的七牛域名 'https' => 'image.mmmx17.cn', //你的HTTPS域名 'custom' => 'static.abc.com', //Useless 没啥用,请直接使用上面的 default 项 ], 'access_key'=> env('QINIU_AK_KEY'), //AccessKey 'secret_key'=> env('QINIU_SK_KEY'), //SecretKey 'bucket' => 'mmmx17cn', //Bucket名字 'notify_url'=> '', //持久化处理回调地址 'access' => 'public', //空间访问控制 public 或 private 'hotlink_prevention_key' => null, // CDN 时间戳防盗链的 key。 设置为 null 则不启用本功能。 ], ...
The configuration of the editor can be found in Simditor Documentation.
Usage
Use it in the form form:
$form->simditor('content');
License
Licensed under The MIT License (MIT).