PHPackages                             cuzy-app/humhub-suneditor - 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. cuzy-app/humhub-suneditor

ActiveLibrary

cuzy-app/humhub-suneditor
=========================

SunEditor rich-text field and renderer for HumHub modules, with inline image/video/audio uploads and automatic orphan-file cleanup.

v1.2.0(today)024↑2650%AGPL-3.0-or-laterPHPPHP &gt;=8.1

Since Aug 9Pushed todayCompare

[ Source](https://github.com/cuzy-app/humhub-suneditor)[ Packagist](https://packagist.org/packages/cuzy-app/humhub-suneditor)[ Docs](https://github.com/cuzy-app/humhub-suneditor)[ RSS](/packages/cuzy-app-humhub-suneditor/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (10)Used By (0)

humhub-suneditor
================

[](#humhub-suneditor)

A [SunEditor](https://github.com/JiHong88/SunEditor) rich-text field for [HumHub](https://www.humhub.com) modules, with inline image/video/audio uploads and automatic cleanup of files a user removes from the content before saving.

Not a HumHub module — there is no `module.json` and nothing to enable. It's a plain Composer library: two widgets, a helper, and an upload action you wire into your own module's controller.

Install
-------

[](#install)

```
composer require cuzy-app/humhub-suneditor
```

Requires the [asset-packagist.org](https://asset-packagist.org) Composer repository to resolve `npm-asset/suneditor` (add it to your module's `composer.json` if it isn't already there — HumHub core needs it too, so it's usually already present at the application root):

```
{
    "repositories": [
        {"type": "composer", "url": "https://asset-packagist.org"}
    ]
}
```

Deliberately **not** a `require` here: `yiisoft/yii2`, `yiisoft/yii2-bootstrap5` and HumHub's own core classes. They're always already loaded by the HumHub application that loads your module — declaring them would install a second, separate copy inside your module's own vendor directory instead of using the one already running, and pulls in `yiisoft/yii2-composer`, a Composer plugin most module vendor directories don't allow-list. Same convention every HumHub module composer.json follows for `humhub/humhub` itself.

Wiring an upload endpoint
-------------------------

[](#wiring-an-upload-endpoint)

`UploadAction` handles the HTTP side (validating the file against the administration area's extension/size settings, storing it, downscaling images). Access control is your controller's job — the action only checks that the request is POST:

```
use cuzyapp\suneditor\actions\UploadAction;

class EditorController extends \humhub\components\Controller
{
    protected function getAccessRules(): array
    {
        return [['login'], ['permission' => YourManagePermission::class]];
    }

    public function actions(): array
    {
        return ['upload' => ['class' => UploadAction::class]];
    }
}
```

Uploads are stored **unattached** — see "Saving and cleanup" below for why.

Authoring: `SuneditorField`
---------------------------

[](#authoring-suneditorfield)

```
use cuzyapp\suneditor\widgets\SuneditorField;
