Redactor Editor Plugin
I'm a complete noob to Vanilla. The only thing stopping me from making the switch is the editor. So now I'm trying to make a editor plugin, and I'm not having much luck. My PHP knowledge is limited...
I have everything for my plugin ready, the images, files, etc. However, I need to be able to change
This:<textarea id="Form_Body" name="Comment/Body" rows="6" cols="100" class="TextBox"></textarea>
To This:<textarea id="redactor_content" name="comment" rows="6" cols="100" class="TextBox"></textarea>
Any suggestions and examples of how I can accomplish this?
Thanks.
Best Answer
-
x00 MVP
one of the key things the live load, as comment editbox are loaded asynchronously.
$('.TextBox').livequery(function(){ $(this).redactor(); }
One of the problem is that as the form is loaded in place, when editing you can have severall Form_Body id which is technically illegal, but hey ho.
Some editor rely of the id so this a problem, there is a workaround, but it can break other plugins, and css that rely on that id not being unique.
I'm hoping that is not the case with redactor. It seem to support multiple editor out of the box.
grep is your friend.
0
Answers
I would look at some of the other plugins that replace the editor to see how they integrate
Vanilla Wiki, Tastes Great! 31,000 viewers can't be wrong. || Plugin Development Explained
I wouldn't bother changing the markup, just uses jquery selector to load it as a appropriate.
$('.TextBox').redactor();
grep is your friend.
one of the key things the live load, as comment editbox are loaded asynchronously.
One of the problem is that as the form is loaded in place, when editing you can have severall Form_Body id which is technically illegal, but hey ho.
Some editor rely of the id so this a problem, there is a workaround, but it can break other plugins, and css that rely on that id not being unique.
I'm hoping that is not the case with redactor. It seem to support multiple editor out of the box.
grep is your friend.
Hmmm... Redactor? That looks like something definitely useful in VanillaBootstrap Mind if I borrow your idea @Xarcell?
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
Go right ahead!
Ok, I'm still trying to figure this out as a learning experience. So far, it's not working. Here's what I have in my default.php:
Code based off of CLEditor Plugin...
Shouldn't it actually be this?
I guess I'm in over my head. I am unable to disable the plugin once enabled.
It also appears this isn't working:
Does your plugin enable? - by the looks of your default.php (unless there are typos) is pretty much impossible to execute.
3 suggestions from the get go
$PluginInfo['redactor'] = array(
should be (if your file directory is RedactorEditor)
$PluginInfo['RedactorEditor'] = array(
'Name' => 'WYSIWYG (redactor)',
if you want to be able to find the plugin in the dashboard without guessing what the descriptive name might be. I immensely dislike plugin names that don't match the plugin name at least with the first word.
'Name' => 'Redactor Editor',
gdn_Plugin has no closing bracket.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
You might also look at the basic structure of most of the approved plugins with regards as to where to put js files, css files, and php files and break the plugin into little pieces and add as you go until you have the complete plugin working.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thanks for your suggestions. I originally has the name as you suggested, but changed it to reflect the CLEditor plugin(approved).
The gnd_plugin closing bracket is on line 65.
Changing the $pluginInfo fixed the problem with it not disabling. I did not realize that it needed to match the directory.
The only problem I see is the livequery isn't working. When I view the source, it still says:
<textarea id="Form_Body" name="Discussion/Body" rows="6" cols="100" class="TextBox" style="overflow: hidden; display: block; "></textarea>
Instead of:
<textarea id="#redactor_content" name="Discussion/Body" rows="6" cols="100" class="TextBox" style="overflow: hidden; display: block; "></textarea>
I have, that's the only reason I've gotten as far as I did.
Here is the updated default.php:
I couldn't get it working either even tough the rendered html and jquery looks good.
However, I did a sample page in the CustomPages plugin and it works:
http://supernepal.com/plugin/page/redactor
Its so much better than cleditor. So It would be nice to get it working.
http://news.ycombinator.com/item?id=4034147
Never mind, got it working!
Great! I hope you intend to release it as a plugin?
Also, did you manage to get images and videos working?
What did you do to get it to work?
Try this:
$Sender->AddCssFile('http://redactorjs.com/js/redactor/css/redactor.css');
$Sender->AddJsFile('http://redactorjs.com/js/jquery-1.7.min.js');
$Sender->AddJsFile('http://redactorjs.com/js/redactor/redactor.js');
I haven't got the images, links working yet, but I am assuming its just a relative path thing.
You can see the Redactor Editor in action here as it's now a part of VanillaBootstrap 2.0a-2.1: http://vanilla.ungdomsrod.dk/
I haven't tested out how it reacts if other editors are enabled though, will test it out tonight if I find the time
Kudos to @Xarcell for the idea and to @x00 for the livequery thingy, that worked out like a charm!
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
I tried that and it still isn't working for me. Can you post your default.php so I can have a look at it?