Yii 1.1: yii-redactorjs-wysiwyg-widget

Redactor Fantastic WYSIWYG-editor on jQuery
47 followers

Yii-RedactorJS-Widget

Yii Widget for the WYSIWYG RedactorJS editor

Requirements

  • JQuery > 1.7.1
  • Browser:
    • Firefox 3+
    • Safari 4+
    • Chrome 4+
    • Opera 10+
    • IE 7+

Installation

  1. Download or Clone the files
  2. 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

Total 20 comments

#16546 report it
samilo at 2014/03/05 02:36am
Direction problem

Direction and Arabic language not worked , trying to add support to RTL . thanks in advance .

#13018 report it
Bjorn at 2013/04/29 01:21am
Update?

This contains redactor v7.6.1. Should be updated because it contains some bugs.

#12825 report it
yJeroen at 2013/04/14 04:23am
Update?

Vince, will you update this extension?

#12729 report it
Rodrigo at 2013/04/08 03:32pm
Redactor is OEM-licensed for Yii
#11425 report it
__construct() at 2013/01/13 07:35pm
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.

#10460 report it
jiaming at 2012/10/29 10:40pm
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

#10300 report it
dvapelnik at 2012/10/18 05:38am
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

#10251 report it
itmagetan at 2012/10/14 11:18am
Need Detailed Example for Image Upload/Choose Script

Could somebody please provide example for Image Upload/Choose Script? Need ASAP. Thanks.

#10064 report it
mihir at 2012/10/03 05:40am
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.

#9534 report it
Tibor Katelbach at 2012/08/21 07:50am
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 ?

#9483 report it
speedyfw at 2012/08/15 09:13am
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>
#8837 report it
tohizma at 2012/07/02 08:43am
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"

#8610 report it
Haensel at 2012/06/14 05:36am
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

#8608 report it
Haensel at 2012/06/14 05:30am
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');
}
#8607 report it
WebDevPT at 2012/06/14 05:16am
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.

#8511 report it
Haensel at 2012/06/08 02:30pm
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!

#8463 report it
rosoft2001 at 2012/06/05 10:02pm
$$$

It's also not free for commercial use (not that it's anything wrong with that, just so you know beforehand)

#8407 report it
Vince. at 2012/05/31 07:04pm
That is not my website

That's not my website, I just created the extension for that editor.

#8404 report it
yJeroen at 2012/05/31 05:06pm
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/

#8344 report it
Vince. at 2012/05/27 11:37pm
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/

Leave a comment

Please to leave your comment.

Create extension