PHPackages                             pjkui/kindeditor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pjkui/kindeditor

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

pjkui/kindeditor
================

Yii2 可以使用的KindEditor富文本编辑器。 KindEditor for Yii2

1.0.1(5y ago)274.4k8MITJavaScriptCI passing

Since Sep 8Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/pjkui/kindeditor)[ Packagist](https://packagist.org/packages/pjkui/kindeditor)[ RSS](/packages/pjkui-kindeditor/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

KindEditor for Yii2
===================

[](#kindeditor-for-yii2)

[![Latest Stable Version](https://camo.githubusercontent.com/b5b043868cbce69bf40837dba8aceabcda0267b24ca38f4345179003aec4e87d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706a6b75692f6b696e64656469746f722e737667)](https://packagist.org/packages/pjkui/kindeditor)[![Total Downloads](https://camo.githubusercontent.com/663ab35ba7edfe20d1c765c3547ba789d4970cc73339a65a98e423a63d533460/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706a6b75692f6b696e64656469746f722e737667)](https://packagist.org/packages/pjkui/kindeditor)[![License](https://camo.githubusercontent.com/76a2317c863ad2d7bef57d4088a186ffda48b698c9dae9b598fb6804c4e53777/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706a6b75692f6b696e64656469746f722e737667)](https://github.com/pjkui/kindeditor/blob/master/license.txt)[![CI](https://github.com/pjkui/kindeditor/actions/workflows/ci.yml/badge.svg)](https://github.com/pjkui/kindeditor/actions/workflows/ci.yml)

A [Yii2](https://www.yiiframework.com/) widget wrapper for the [KindEditor](http://kindeditor.net) WYSIWYG HTML editor, with file upload and file-manager endpoints included.

> **Note:** This fork patches several Linux-specific bugs that the upstream YiiChina package could not be updated with. Please follow the usage instructions in this README — examples elsewhere may contain typos that cannot be corrected there.

---

**Languages:** [English](#english) · [中文](#%E4%B8%AD%E6%96%87)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Editor Types](#editor-types)
- [Configuration](#configuration)
- [Upload Action Options](#upload-action-options)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [中文文档](#%E4%B8%AD%E6%96%87)

---

English
-------

[](#english)

### Features

[](#features)

- Full Yii2 `InputWidget` integration — works with or without an `ActiveForm` model.
- Six editor modes: full rich-text editor, upload button, color picker, file manager, image dialog, file dialog.
- Bundled upload + file-manager action with extension whitelisting and size limits.
- Ships the complete KindEditor 4.x assets (plugins, themes, i18n).

### Requirements

[](#requirements)

ComponentVersionPHP&gt;= 5.6 (7.4+ recommended)Yii2^2.0### Installation

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
composer require pjkui/kindeditor "*"
```

Or add the following to the `require` section of your `composer.json`:

```
"pjkui/kindeditor": "*"
```

Manual installation (not recommended)If you copy the package into `vendor/` without Composer, add the following line to `vendor/composer/autoload_psr4.php` so the classes are autoloaded:

```
'pjkui\\kindeditor\\' => array($vendorDir . '/pjkui/kindeditor'),
```

### Quick Start

[](#quick-start)

**1. Register the upload action in your controller:**

```
public function actions()
{
    return [
        'Kupload' => [
            'class' => 'pjkui\kindeditor\KindEditorAction',
        ],
    ];
}
```

> ⚠️ The action id **must** be `Kupload` — the widget hard-codes this route when generating `uploadJson` / `fileManagerJson` URLs.

**2. Render the widget in your view:**

```
use pjkui\kindeditor\KindEditor;

// Standalone
echo KindEditor::widget([]);

// Bound to a model attribute
echo $form->field($model, 'content')->widget(KindEditor::class, [
    'clientOptions' => [
        'allowFileManager' => 'true',
        'allowUpload'      => 'true',
    ],
]);
```

### Editor Types

[](#editor-types)

Set `editorType` to switch between rendering modes:

`editorType`Description*(default)*Full rich-text editor on a ```uploadButton`Text input + "Upload" button for single-file upload`colorpicker`Text input + button that opens a color picker`file-manager`Text input + button that opens the server file browser`image-dialog`Text input + button that opens the image upload dialog`file-dialog`Text input + button that opens the generic file dialogExample — image upload dialog bound to an `article_pic` attribute:

```
echo $form->field($model, 'article_pic')->widget(KindEditor::class, [
    'clientOptions' => [
        'allowFileManager' => 'true',
        'allowUpload'      => 'true',
    ],
    'editorType' => 'image-dialog',
]);
```

### Configuration

[](#configuration)

All editor options are passed through the `clientOptions` array. See the [official KindEditor documentation](http://kindeditor.net/doc.php) for the full list.

Full example with a custom toolbar:

```
use pjkui\kindeditor\KindEditor;

echo KindEditor::widget([
    'id' => 'thisID', // id of the generated textarea
    'clientOptions' => [
        'height' => '500',
        'items'  => [
            'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code',
            'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyfull',
            'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent',
            'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
            'fullscreen', '/',
            'formatblock', 'fontname', 'fontsize', '|',
            'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough',
            'lineheight', 'removeformat', '|',
            'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr',
            'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about',
        ],
    ],
]);
```

### Upload Action Options

[](#upload-action-options)

`KindEditorAction` accepts the following properties when registered in `actions()`:

PropertyDefaultDescription`php_path``@webroot/`Server filesystem path used as the PHP root`php_url``@web/`URL that maps to `php_path``root_path``{php_path}upload/`Upload root on the filesystem`root_url``{php_url}upload/`Upload root URL`save_path``{root_path}`Where new files are written`save_url``{root_url}`URL prefix for new files`max_size``1000000` (bytes)Maximum upload size`ext_arr`see sourceAllowed extensions keyed by `image`/`flash`/`media`/`file`Example — override the upload directory:

```
public function actions()
{
    return [
        'Kupload' => [
            'class'     => 'pjkui\kindeditor\KindEditorAction',
            'root_path' => Yii::getAlias('@webroot') . '/attached/',
            'root_url'  => Yii::getAlias('@web')    . '/attached/',
            'max_size'  => 5 * 1024 * 1024, // 5 MB
        ],
    ];
}
```

### Testing

[](#testing)

This repository uses [PHPUnit](https://phpunit.de/) for unit tests.

```
composer install
composer test
# or run directly:
vendor/bin/phpunit
```

### Contributing

[](#contributing)

Bug reports and pull requests are welcome on [GitHub](https://github.com/pjkui/kindeditor). Please make sure `composer test` passes before opening a PR.

### License

[](#license)

Released under the [MIT License](license.txt). KindEditor itself is distributed under its original [LGPL license](http://kindeditor.net/license.php).

---

中文
--

[](#中文)

Yii2 专用的 KindEditor 富文本编辑器封装，内置上传与文件管理 Action。

> **说明：** 本分支修复了一些 Linux 环境下的 Bug，由于 Yii China 无法更新上游，请以本 README 为准。

### 环境要求

[](#环境要求)

组件版本PHP&gt;= 5.6（推荐 7.4+）Yii2^2.0### 安装

[](#安装)

推荐使用 Composer：

```
composer require pjkui/kindeditor "*"
```

或将以下内容加入 `composer.json` 的 `require` 部分：

```
"pjkui/kindeditor": "*"
```

手动安装（不推荐）如果直接把包放入 `vendor/`，需在 `vendor/composer/autoload_psr4.php` 中添加：

```
'pjkui\\kindeditor\\' => array($vendorDir . '/pjkui/kindeditor'),
```

### 快速开始

[](#快速开始)

**1. 在控制器中注册上传 Action：**

```
public function actions()
{
    return [
        'Kupload' => [
            'class' => 'pjkui\kindeditor\KindEditorAction',
        ],
    ];
}
```

> ⚠️ Action 名字**必须**是 `Kupload`，因为 Widget 在生成上传 URL 时硬编码了这个名字。

**2. 在视图中渲染：**

```
use pjkui\kindeditor\KindEditor;

echo KindEditor::widget([]);

// 或绑定到模型字段
echo $form->field($model, 'content')->widget(KindEditor::class, [
    'clientOptions' => [
        'allowFileManager' => 'true',
        'allowUpload'      => 'true',
    ],
]);
```

### `editorType` 配置

[](#editortype-配置)

`editorType`说明*(默认)*富文本编辑器`uploadButton`自定义文件上传按钮`colorpicker`取色器`file-manager`文件管理器`image-dialog`图片上传对话框`file-dialog`文件上传对话框示例 —— 图片上传对话框：

```
echo $form->field($model, 'article_pic')->widget(KindEditor::class, [
    'clientOptions' => [
        'allowFileManager' => 'true',
        'allowUpload'      => 'true',
    ],
    'editorType' => 'image-dialog',
]);
```

### 完整示例

[](#完整示例)

```
use pjkui\kindeditor\KindEditor;

echo KindEditor::widget([
    'id' => 'thisID',
    'clientOptions' => [
        'height' => '500',
        'items'  => [
            'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code',
            'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyfull',
            'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent',
            'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
            'fullscreen', '/',
            'formatblock', 'fontname', 'fontsize', '|',
            'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough',
            'lineheight', 'removeformat', '|',
            'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr',
            'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about',
        ],
    ],
]);
```

更多 `clientOptions` 参数请参考 [KindEditor 官方文档](http://kindeditor.net/doc.php)。

### 测试

[](#测试)

```
composer install
composer test
```

### 许可证

[](#许可证)

MIT License，详见 [license.txt](license.txt)。

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance57

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2125d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6873307?v=4)[Quinn Pan](/maintainers/pjkui)[@pjkui](https://github.com/pjkui)

---

Top Contributors

[![pjkui](https://avatars.githubusercontent.com/u/6873307?v=4)](https://github.com/pjkui "pjkui (29 commits)")

---

Tags

javascriptkindeditorphprich-edtorrich-text-editorrichtexteditor

### Embed Badge

![Health badge](/badges/pjkui-kindeditor/health.svg)

```
[![Health](https://phpackages.com/badges/pjkui-kindeditor/health.svg)](https://phpackages.com/packages/pjkui-kindeditor)
```

###  Alternatives

[redaxo/source

REDAXO CMS source repository (for static analysis)

34922.4k4](/packages/redaxo-source)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
