Skip to content

Commit

Permalink
feat: doc
Browse files Browse the repository at this point in the history
  • Loading branch information
krissss committed Aug 31, 2017
1 parent b7a7a12 commit 6fa9771
Showing 1 changed file with 51 additions and 13 deletions.
64 changes: 51 additions & 13 deletions README.md
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
]);
```

0 comments on commit 6fa9771

Please sign in to comment.