Yii-RedactorJS-Widget ¶
- Using with a model
- Using with a model and a mini toolbar and different language
- Using with a model and custom toolbar options
- Using with a name and value
Yii Widget for the WYSIWYG RedactorJS editor
Requirements ¶
- JQuery > 1.7.1
- Browser:
- Firefox 3+
- Safari 4+
- Chrome 4+
- Opera 10+
- IE 7+
Installation ¶
- Download or Clone the files
- Extract into the widgets folder or extensions folder
Usage ¶
Using with a model ¶
$this->widget('application.widgets.redactorjs.Redactor', array( 'model' => $model, 'attribute' => 'some_attribute' ));
Using with a model and a mini toolbar and different language ¶
$this->widget('application.widgets.redactorjs.Redactor', array( 'lang' => 'de', 'toolbar' => 'mini', 'model' => $model, 'attribute' => 'some_attribute' ));
- There are two toolbars supported right now: default & mini. By default the widget will load the 'default' toolbar.
- Supported languages currently: de, en, fr, lv, pl, pt_br, ru, ua
Using with a model and custom toolbar options ¶
$this->widget('application.widgets.redactorjs.Redactor', array( 'editorOptions' => array('autoresize' => true, 'fixed' => true), 'model' => $model, 'attribute' => 'some_attribute' ));
- Referrer to the redactorjs API for the list of supported elements. View Docs
Using with a name and value ¶
$this->widget('application.widgets.redactorjs.Redactor', array( 'name' => 'some name', 'value' => 'some value' ));
Authors ¶
Vincent Gabriel http://vadimg.com
well done vince ! i like it
beautiful editor and can works well with the fancybox and jqueryUi dialog . but the doc is Russian ; so does it support custom toolbar button (add custom button and functionality ,some times these will named editor plugin)
Can't read russian either
To be honest i can't read russian either. But from their website in English i was able to check out their road map which states that the next thing is Plugin Support.
http://redactorjs.com/en/roadmap/
English
It looks really good, but could you please add some internationalization on your website? A lot of your pages are in russian and I prefer not to use Chrome auto-translate. ;)
@yiqing95, apparently you can.. See: http://redactorjs.com/docs/toolbar/
That is not my website
That's not my website, I just created the extension for that editor.
$$$
It's also not free for commercial use (not that it's anything wrong with that, just so you know beforehand)
Awesome editor
Thanks for your work. Didn't know about redactor but this is a beautiful editor. It would be really cool to enable image uploads via a CAction that could be plugged into the controller of choice to make image uploads as easy as possible. But this is just a suggestion.
Thanks again!
Very cool extension! Keep it up.
Very cool extension. And easy to run.
An example on how we can use the upload feature would be awesome.
Image upload
I use something like that for image uploads. Image is a CFormModel where file is specified with a "file" validator only allowing image files to be accepted. This is a bit simplified. Maybe checking the filenames before using them would be more secure but you get the idea
public function actionImageUpload() { $image=new Image; $image->file=CUploadedFile::getInstanceByName('file'); if($image->validate()) { if($image->file->saveAs(Yii::app()->basePath.'/../images/'.$image->file->name)) { echo CHtml::image(Yii::app()->baseUrl.'/images/'.$image->file->name); Yii::app()->end(); } } throw new CHttpException(403,'The server is crying in pain as you try to upload bad stuff'); }
Image previews
And here is an example for outputting the JSON used to show the image previews of already uploaded images. Again, simplified. It doesn't check whether a file really is an image, so you may wanna add checks so that it doesn't try to show an pdf file or something like that :)
public function actionUploadedImages() { $images = array(); $handler = opendir(Yii::app()->basePath.'/../images'); while ($file = readdir($handler)) { if ($file != "." && $file != "..") $images[] = $file; } closedir($handler); $jsonArray=array(); foreach($images as $image) $jsonArray[]=array( 'thumb'=>Yii::app()->baseUrl.'/images/'.$image, 'image'=>Yii::app()->baseUrl.'/images/'.$image ); header('Content-type: application/json'); echo CJSON::encode($jsonArray); }
Hope it helps a bit
entering editorOptions
how to enter editorOptions imageUpload and fileUpload correctly?
'editorOptions' => array('imageUpload' => '/testscript/image_upload.php')
always give result prepended with backslash on path
$('#editor').redactor({"imageUpload":"\/testscript\/image_upload.php"
entering editorOptions - solution
<div class="row"> <?php echo $form->labelEx($model,'description'); ?> <?php $this->widget( 'ext.widgets.redactorjs.Redactor', array( 'editorOptions' => array( 'imageUpload' => Yii::app()->createAbsoluteUrl('roundtrip/upload'), 'imageGetJson' => Yii::app()->createAbsoluteUrl('roundtrip/listimages') ), 'model' => $model, 'attribute' => 'description' )); ?> </div>
doesn't work in Ajax context
Hi Thanks for the great extension
it works fine in a normal page load context
but doesn't work if the widget sits in an ajax rendered view
any idea what could be added to solve this ?
Promising one
Its very cool and easy to integrate but the deal is with imageupload, file upload and all functionality. It would be great if you can provide an example with the code.
Need Detailed Example for Image Upload/Choose Script
Could somebody please provide example for Image Upload/Choose Script? Need ASAP. Thanks.
editor buttons
hi to all!
How a can edit toolbar buttons?
I want remove some buttons, but i can do it. How to use array 'editorOptions' for my problem?
thx
Not works in Firefox. Ajax security alert
This editor not works in Firefox.
It always gives me Ajax security alert like
NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLDocument.execCommand]
Any ideas? Thanks so much for this great contribution
Original Redactor plugin is no more under public domain
Text from official form site FAQ:
Can I use Redactor in my project, which is published under GPL, MIT, BSD, or other open-source/copyleft license?
Yes, go ahead! You just need to purchase the OEM license. No additional fees will be applied and there are no special terms or conditions, until Redactor is properly "linked" in your software.
However, keep in mind that Redactor is not an open-source product. It is proprietary commercial copyrighted software and we do not allow it's distribution under any open-source licenses. Think about Redactor as if it was a paid proprietary extension for your project.
imperavi.com/redactor/faq/
Looks like we can't use it without puscashing licence.
Redactor is OEM-licensed for Yii
Take a look at http://www.yiiframework.com/news/64/redactor-is-oem-licensed-for-yii/
Update?
Vince, will you update this extension?
Update?
This contains redactor v7.6.1. Should be updated because it contains some bugs.
Direction problem
Direction and Arabic language not worked , trying to add support to RTL .
thanks in advance .
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.