Has anyone been able to extend the Rich Text Editor yet? I’d like to add a tool, but I can’t seem to get the example in the docs working.
I’ve noticed that when adding the globals() function, I also need to create a language file, but that doesn’t seem to be the problem. I’ve also noticed that the definition() function has a return value that opens and closes with a single quote and has a single quote variable in the WysiHat.addButton function within it. I changed some of those to double quotes but that didn’t help either.
I’ve placed the strip_tags folder in the third_party folder and it doesn’t appear anywhere. Where is it supposed to appear? I’ve checked the list for every different type of add-on and the list in the RTE Module Settings, but nothing is showing up anywhere. I can’t even get a die() statement in my RTE tool to kill the page.
My code is below. Any help would be wonderful. I’m comfortable troubleshooting once I start seeing errors but so far…
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Strip_tags_rte {
public $info = array(
'name' => 'Strip Tags',
'version' => '1.0',
'description' => 'Strips all block and phrase-level formatting elements',
'cp_only' => 'n'
);
private $EE;
/**
* Constructor
*/
function __construct()
{
// Make a local reference of the ExpressionEngine super object
$this->EE =& get_instance();
}
/**
* Globals we need defined
*/
function globals()
{
$this->EE->lang->loadfile('strip_tags');
return array(
'rte.strip_tags.label' => lang('strip_tags')
);
}
/**
* RTE tool Definition
*/
function definition()
{
return "
WysiHat.addButton('strip_tags', {
label: EE.rte.strip_tags.label,
handler: function()
{
// Strip tags logic
alert('dog');
}
});
";
}@litzinger
Thank you for your suggestion. Could you give us an example of what those stubbed out files would like? I have been trying to figure it out for the past 30 minutes and could not wrap my head around it. All I was able to produce were some PHP errors in the backend …
That helps get it installed.
I’ve discovered one more thing that is making this a confusing example too. It seems the RTE language file (/expressionengine/language/english/rte_lang.php) also has a line naming the Strip Tags field “Clear Formatting” (ln 78: ‘strip_tags_rte’ => ‘Clear Formatting’,) so no matter what you try to name your addon, it gets overwritten with this.
I know this topic is a little old, but I just ran across this issue and created a module for installing these RTE tools. https://github.com/jbueler/RTEToolManager thought it might help someone else out.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.