craftcms / redactor
Edit rich text content in Craft CMS using Redactor by Imperavi.
Installs: 2 473 124
Dependents: 71
Suggesters: 0
Security: 0
Stars: 100
Watchers: 13
Forks: 49
Open Issues: 65
Language:JavaScript
Type:craft-plugin
Requires
- php: ^8.2
- craftcms/cms: ^5.3.0
- craftcms/html-field: ^3.0.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- craftcms/rector: dev-main
- 4.x-dev
- 4.2.0
- 4.1.0
- 4.0.0
- 3.x-dev
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-beta.3
- 3.0.0-beta.2
- 3.0.0-beta.1
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.1
- 2.9.0
- 2.8.8
- 2.8.7
- 2.8.6
- 2.8.5
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0.1
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.3.2
- 2.3.3.1
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0.1
- 2.0.0
- 1.1.0
- 1.0.1
- 1.0.0.1
- 1.0.0
- 1.0.0-beta.1
- dev-dependabot/composer/craftcms/cms-4.4.12
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
- dev-feature/drop-postactionrequeset
- dev-bugfix/changelog-heading-level
- dev-release/2.2
- dev-features/redactor3.1.1
This package is auto-updated.
Last update: 2024-09-03 13:39:29 UTC
README
Redactor
This plugin adds a “Redactor” field type to Craft CMS, which provides a rich text editor powered by Redactor by Imperavi.
Requirements
This plugin requires Craft CMS 4.0 or later.
Installation
You can install this plugin from the Plugin Store or with Composer.
From the Plugin Store
Go to the Plugin Store in your project’s Control Panel and search for “Redactor”. Then click on the “Install” button in its modal window.
With Composer
Open your terminal and run the following commands:
# go to the project directory cd /path/to/my-project.test # tell Composer to load the plugin composer require craftcms/redactor # tell Craft to install the plugin ./craft install/plugin redactor
Configuration
Redactor Configs
You can create custom Redactor configs that will be available to your Redactor fields. They should be created as JSON files in your config/redactor/
folder.
For example, if you created a config/redactor/Standard.json
file with the following content:
{ "buttons": ["html", "format", "bold", "italic", "lists", "link", "file"], "plugins": ["fullscreen"] }
…then a “Standard” option would become available within the “Redactor Config” setting on your Redactor field’s settings.
See the Redactor documentation for a list of available config options and buttons.
Craft Redactor config options
Craft addes the enforceButtonOrder
config option that can be set to a list of button names in the expected order. This option should be used to address the uncontrollable button order set by Redactor when adding plugins to the configuration.
HTML Purifier Configs
Redactor fields use HTML Purifier to ensure that no malicious code makes it into its field values, to prevent XSS attacks and other vulnerabilities.
You can create custom HTML Purifier configs that will be available to your Redactor fields. They should be created as JSON files in your config/htmlpurifier/
folder.
Copy Default.json as a starting point, which is the default config that Redactor fields use if no custom HTML Purifier config is selected.
See the HTML Purifier documentation 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.
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 are bundled by default. To enable them, just add the plugin handle to the plugin
array in your Redactor config.
{ "plugins": ["alignment", "fullscreen"] }
You can also supply your own Redactor plugins by saving them in your config/redactor/
folder. You can either place the plugin directly in that folder, or within a subfolder that is named after the plugin:
config/
└── redactor/
└── plugins/
├── foo.js
└── bar/
└── bar.js
Other Craft plugins can supply additional Redactor JS plugin locations using the craft\redactor\Field::EVENT_REGISTER_PLUGIN_PATHS
event.