Integrating a Rich Text Editor¶
Build your own wysiwyg plugin.
Elgg is bundled with a plugin for CKEditor, and previously shipped with TinyMCE support. However, if you have a wysiwyg that you prefer, you could use this tutorial to help you build your own.
All forms in Elgg should try to use the provided input views located in
If these views are used, then it is simple for plugin authors to replace a view,
in this case
input/longtext, with their wysiwyg.
Add the WYSIWYG library code¶
Now you need to upload TinyMCE into a directory in your plugin.
We strongly encourage you to use
composer to manage third-party dependencies,
since it is so much easier to upgrade and maintain that way:
composer require npm-asset/tinymce
Tell Elgg when and how to load TinyMCE¶
Now that you have:
- created your start file
- intialized the plugin
- uploaded the wysiwyg code
It is time to tell Elgg how to apply TinyMCE to longtext fields.
We’re going to do that by extending the
Create a view
tinymce/longtext and add the following code:
Then, in your plugin’s
elgg-plugin.php file extend the
return [ 'view_extensions' => [ 'input/longtext' => [ 'tinymce/longtext' => , ], ], ];
That’s it! Now every time someone uses
input/longtext TinyMCE will be loaded and applied to that textarea.