PHP code example of quansitech / qscmf-formitem-ueditor
1. Go to this page and download the library: Download quansitech/qscmf-formitem-ueditor library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
quansitech / qscmf-formitem-ueditor example snippets
composer
->addFormItem('desc', 'ueditor', '商家简介')
//addFormItem第七个参数,传递指定的上传处理地址,加上url_prefix参数和url_suffix
//拼接出的url结果: url_prefix . url原来的相对路径. url_suffix
->addFormItem('desc', 'ueditor', '商家简介', '', '', '', 'data-url="/extends/ueditor/index?url_prefix=prefix地址&url_suffix=后缀"')
//场景举例:
//某些管理员在上传富文本图片时,会上传一张非常大的图片,这样会导致用户访问该页面异常缓慢
//这时可以利用url_prefix配合imageproxy做到自动降低图片大小,降低图片占用的网络带宽
$url_prefix = U('/ip/q90', '', false, true) . '/' . U('/', '', false, true);
//url_prefix = http://域名/ip/q90/http://域名/图片地址
->addFormItem('desc', 'ueditor', '商家简介', '', '', '', 'data-url="/extends/ueditor/index?url_prefix=' . $url_prefix . '"')
// 使用CDN
$domain = HTTP_PROTOCOL . "://" . SITE_URL;
$url_prefix = injecCdntUrl();
->addFormItem("content", "ueditor", "内容", "", "", "", "data-url=$domain/extends/ueditor/index?type=editor&url_prefix=$url_prefix data-forcecatchremote='true'")
//addFormItem第七个参数,设置data-forcecatchremote="true"
->addFormItem('desc', 'ueditor', '商家简介', '', '', '', 'data-forcecatchremote="true"')
//在Common/Conf/config.php中新增配置值
'CUSTOM_UEDITOR_JS_CONFIG' => __ROOT__ . '/Public/static/ueditor.config.js' //注意必须加上__ROOT__,为了兼容根目录是网站子路径的情况
//如:想通过form.options来配置ue的toolbars参数
//组件会自动完成php数组--》js json对象的转换,并传入ue中
->addFormItem('content', 'ueditor', '内容', '', ['toolbars' => [['attachment']]])
全局配置
1.先COPY ueditor.config.js 文件到项目路径,重新指定JS CONFIG路径
2.修改ueditor.config.js 的customColors配置项,第一行10色块为主题色块, 最后一行10色块为标准色块,可按照需要自行增删改里面的色值。
局部配置
1. 在Formbuilder设置formItem时,可传递customColors的设置,详细方法查看“设置ue的option参数”
use FormItem\Ueditor\Lib\UeditorAuth;
UeditorAuth::enable();
UeditorAuth::disable();