This plugin adds a “Redactor” field type to Craft CMS, which provides a rich text editor powered by Redactor by Imperavi.
This plugin requires Craft CMS 3.1.0 or later.
You can install this plugin from the Plugin Store or with Composer.
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.
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
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.
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.
Use this as a starting point, which is the default config that Redactor fields use if no custom HTML Purifier config is selected:
{
"Attr.AllowedFrameTargets": ["_blank"],
"Attr.EnableID": true,
"HTML.AllowedComments": ["pagebreak"]
}
(The HTML.AllowedComments option is required for the pagebreak
plugin.)
See the HTML Purifier documentation for a list of available config options.
All 1st 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.