Skip to content

Commit

Permalink
Document EVENT_MODIFY_PURIFIER_CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jun 13, 2023
1 parent 0e60635 commit beebdf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ Copy [Default.json](https://github.com/craftcms/craft/blob/main/config/htmlpurif

See the [HTML Purifier documentation](http://htmlpurifier.org/live/configdoc/plain.html) for a list of available config options.

For advanced customization, you can modify the `HTMLPurifier_Config` object directly via the `craft\redactor\Field::EVENT_MODIFY_PURIFIER_CONFIG` event.

```php
use craft\htmlfield\events\ModifyPurifierConfigEvent;
use craft\redactor\Field;
use HTMLPurifier_Config;
use yii\base\Event;

Event::on(
Field::class,
Field::EVENT_MODIFY_PURIFIER_CONFIG,
function(ModifyPurifierConfigEvent $event) {
/** @var HTMLPurifier_Config $config */
$config = $event->config;
// ...
}
);
```

### Redactor JS Plugins

All [first party Redactor JS plugins](https://imperavi.com/redactor/plugins/) are bundled by default. To enable them, just add the plugin handle to the `plugin` array in your Redactor config.
Expand Down
8 changes: 5 additions & 3 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ class Field extends HtmlField
* Plugins can get notified when HTML Purifier config is being constructed.
*
* ```php
* use craft\htmlfield\events\ModifyPurifierConfigEvent;
* use craft\redactor\Field;
* use craft\htmlfield\ModifyPurifierConfigEvent;
* use HTMLPurifier_AttrDef_Text;
* use HTMLPurifier_Config;
* use yii\base\Event;
*
* Event::on(
* Field::class,
* Field::EVENT_MODIFY_PURIFIER_CONFIG,
* function(ModifyPurifierConfigEvent $event) {
* // ...
* // @var HTMLPurifier_Config $config
* $config = $event->config;
* // ...
* }
* );
* ```
Expand Down

0 comments on commit beebdf7

Please sign in to comment.