Drupal has no wysiwyg editor in core, but the fact is that practically all end users ask for it. In this article I will explain how to add a wysiwyg editor to a Drupal site.
What wysiwyg editor do you want?
The first two steps are, as usual, the requirements and the module selection. Let's assume we have a site with two groups of users:
- Trusted editors. They have accounts on the site, write articles regularly, but are not very familiar with HTML. The articles mainly consist of text, links, tables and sometimes images. Long articles are prepared in MS Word and copied into the website. Short articles are directly edited on the site. SEO is important, so the use of header-tags should be enforced.
- Anonymous visitors. They don't have an account on the site, They comment on articles and on each other's comments. They only add text, images are not allowed.
Pick a module
In Drupal 7 the Wysiwyg module is the de-facto standard for adding a wysiwyg editor. It supports various wysiwyg editor libraries, such as TinyMCE and CKEditor. The alternative is the CKEditor module, a module specialized to support the CKEditor. I always use the Wysiwyg module. You can find a full list of wysiwyg modules at the end of this article.
For adding a wysiwyg editor to the site you need to use an integration module (e.g. Wysiwyg, CKEditor) plus the actual editor library. These editors are separate projects and can be downloaded elsewhere from the web. Integration modules contain documentation of the location where to download the editor(s).
Set up Text formats
The Wysiwyg module uses Text formats to apply an editor. Therefore, you need to set up a text format for the wysiwyg editor of your choice. If you plan to use multiple editors, create one text format for each editor.
Visit: Configuration > Content authoring > Text formats
Drupal has by default three text formats, Filtered HTML, Full HTML and Plain text. In this use case the users of the wysiwyg editor are trusted users, so there is no need to filter the HTML they enter with their text. You can modify the Full HTML text format for use with the wysiwyg editor. The Filtered HTML text format will not be used and can be disabled.
Modify the Full HTML text format configuration with the following:
- Name: Wysiwyg
- Role: Editor and Administrator
- Enabled filters: Correct faulty and chopped off HTML.
- Disable the other filters as they may cause undesired effects.

You can leave the Plain text format as it is for use by anonymous visitors. When experimenting with the filters (which I encourage), be carefull with the Filter processing order. Processing filters in the wrong sequence may break things or result in unsafe input. The image below shows the default filter processing order.

And now the Wysiwyg module
Download, install and enable the Wysiwyg module as usual.
Visit: Configuration > Content authoring > Wysiwyg profiles
When no editor libraries are installed yet, the installation instructions will appear. Follow the instruction of the editor of your choice. In this article the TinyMCE editor will be used. But do look at the other editors and try them out before making a choice.
Refresh the configuration page after you have downloaded, extracted and placed the library in the file system of your site. Select the TinyMCE editor for the Wysiwyg text format.

For a minimum configuration of the TinyMCE profile, edit the profile and select, for example, Bold and Italic under 'Buttons and plugins'. Save the configuration. Now create some content, for example a Basic page, which uses a text field with text formats.

You now have a basic wysiwyg editor in your Drupal website.
Read more on advanced wysiwyg configuration in a future article.
About security
Note that in this example we have used a minimum security policy for those using the wysiwyg editor. All HTML, scripts, embeds, etc. are allowed! Never use this configuration for anonymous or non-trusted users. If you have different user groups with different security levels, create a text format per group/role and configure the wysiwyg editor for each text format. The text format permissions determine which roles can use the wysiwyg editor.
List of Drupal wysiwyg modules
Wysiwyg module
Popular, supports various editor libraries.
CKEditor - WYSIWYG HTML editor
Popular, for CKEditor only.
BUEditor module
Used on drupal.org, requires html knowledge.
Aloha module
Under development.
Reacties
thanks Erik! Made it much more clear for me.
2 questions remain for me:
- Will renaming Full-html to wysiwyg not break compatibility with other modules or future updates?
- Could html-filter/-tidying from drupal interfer with the one from the Wysiwyg-editor (most of them do that)?
dennis
I don't expect renaming a text format to break compatibility. The filters are identified with an ID number, not the name. And further, modules should apply the filter which is selected by the user.
Filtering by Drupals text formats may interfere with the wysiwyg editor. In my next article you can read about configuration of the Wysiwyg module and how this relates to the text formats. If you find yourself debugging the wysiwyg/text format behavior, use the unformatted input as your reference. That is the data you see in the text input field when you disable the wysiwyg editor.
Just a note on the Aloha module. The current active development is happening here http://drupal.org/sandbox/iler/1403780 meanwhile we are trying to get maintainer permission on the original project.
That is very good news. About a year ago at Drupal Gov Days in Brussels I got introduced to the Aloha editor and it impressed me. But the development of the Drupal module seemed to got stuck. I need to make some time to checkout the status of your recent development. Thanks for the update.
SiteFeantee xaikalitag Chinkillult http://usillumaror.com - iziananatt AWARAGEDSPEDS http://gussannghor.com Zewgriess
SiteFeantee xaikalitag Chinkillult http://usillumaror.com - iziananatt AWARAGEDSPEDS http://gussannghor.com Zewgriess
I always love wysiwyg module!
http://www.ifeel.edu.in
Reactie toevoegen