-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,69 @@ | ||
Yii2 wangeditor widget | ||
Yii2 wangEditor widget | ||
====================== | ||
Yii2 wangeditor widget | ||
|
||
Installation | ||
------------ | ||
Yii2 wangEditor widget | ||
|
||
The preferred way to install this extension is through [composer](http://getcomposer.org/download/). | ||
[wangEditor 官网](http://www.wangeditor.com/) | ||
|
||
Either run | ||
安装 | ||
------------ | ||
|
||
``` | ||
php composer.phar require --prefer-dist kriss/yii2-wang-editor "*" | ||
``` | ||
|
||
or add | ||
使用 | ||
----- | ||
|
||
``` | ||
"kriss/yii2-wang-editor": "*" | ||
基本当 widget 使用: | ||
|
||
```php | ||
echo \kriss\wangEditor\WangEditorWidget::widget([ | ||
'name' => 'inputName', | ||
]); | ||
``` | ||
|
||
to the require section of your `composer.json` file. | ||
放在 ActiveForm 中使用: | ||
|
||
```php | ||
$form = new \yii\widgets\ActiveForm(); | ||
echo $form->field($model, 'content')->widget(\kriss\wangEditor\WangEditorWidget::className()); | ||
``` | ||
|
||
Usage | ||
配置 | ||
----- | ||
|
||
Once the extension is installed, simply use it in your code by : | ||
## clientJs 客户端 js 扩展 | ||
|
||
可替换变量: | ||
|
||
- `{name}`:editor实例 | ||
- `{hiddenInputId}`:隐藏输入域的id | ||
|
||
配置举例: | ||
|
||
```php | ||
'clientJs' => <<<JS | ||
// 设置上传文件路径 | ||
{name}.customConfig.uploadImgServer = '/upload/wang'; | ||
// 将富文本的数据更改后加入到隐藏域,该方法默认已经配置,不需要重复写,可以覆盖写 | ||
{name}.customConfig.onchange = function (html) { | ||
$('#{hiddenInputId}').val(html); | ||
} | ||
JS | ||
``` | ||
|
||
更多配置见[官网配置](https://www.kancloud.cn/wangfupeng/wangeditor3/332599) | ||
|
||
完整例子设置图片上传的路径 | ||
----- | ||
|
||
```php | ||
<?= \kriss\wangEditor\AutoloadExample::widget(); ?>``` | ||
$clientJs = <<<JS | ||
{name}.customConfig.uploadImgServer = '/upload/wang'; | ||
JS; | ||
echo \kriss\wangEditor\WangEditorWidget::widget([ | ||
'name' => 'content', | ||
'clientJs' => $clientJs | ||
]); | ||
``` |