• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    PHP
  • Created over 9 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yii 2 widget for the Froala WYSIWYG HTML Editor.

Yii Framework Froala WYSIWYG HTML Editor

Packagist Packagist

Yii 2 widget for Froala Wysiwyg editor.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist froala/yii2-froala-editor

or add

"froala/yii2-froala-editor": "^3.2.5"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php echo froala\froalaeditor\FroalaEditorWidget::widget([
    'name' => 'content',
    'options' => [
        // html attributes
        'id'=>'content'
    ],
    'clientOptions' => [
        'toolbarInline'=> false,
        'theme' =>'royal', //optional: dark, red, gray, royal
        'language'=>'en_gb' // optional: ar, bs, cs, da, de, en_ca, en_gb, en_us ...
    ]
]); ?>

or use with a model:

<?php echo froala\froalaeditor\FroalaEditorWidget::widget([
    'model' => $model,
    'attribute' => 'content',
    'options' => [
        // html attributes
        'id'=>'content'
    ],
    'clientOptions' => [
        'toolbarInline' => false,
        'theme' => 'royal', //optional: dark, red, gray, royal
        'language' => 'en_gb' // optional: ar, bs, cs, da, de, en_ca, en_gb, en_us ...
    ]
]); ?>

add Font-awesome cdn for font-awesome plugin

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

Upload example

Using the basic Yii template make a new folder under /web/ called uploads.

For controler:

public function actionUpload() {
    $base_path = Yii::getAlias('@app');
    $web_path = Yii::getAlias('@web');
    $model = new UploadForm();

    if (Yii::$app->request->isPost) {
        $model->file = UploadedFile::getInstanceByName('file');

        if ($model->validate()) {
            $model->file->saveAs($base_path . '/web/uploads/' . $model->file->baseName . '.' . $model->file->extension);
        }
    }

    // Get file link
    $res = [
        'link' => $web_path . '/uploads/' . $model->file->baseName . '.' . $model->file->extension,
    ];

    // Response data
    Yii::$app->response->format = Yii::$app->response->format = Response::FORMAT_JSON;
    return $res;
}

For model:

namespace app\models;
use yii\base\Model;
use yii\web\UploadedFile;

/**
 * UploadForm is the model behind the upload form.
 */
class UploadForm extends Model
{
    /**
     * @var UploadedFile|Null file attribute
     */
    public $file;

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            [['file'], 'file']
        ];
    }
}

For the view:

<?= \froala\froalaeditor\FroalaEditorWidget::widget([
    'name' => 'body',
    'clientOptions' => [
        'toolbarInline'=> false,
        'height' => 200,
        'theme' => 'royal',//optional: dark, red, gray, royal
        'language' => 'en_gb' ,
        'toolbarButtons' => ['fullscreen', 'bold', 'italic', 'underline', '|', 'paragraphFormat', 'insertImage'],
        'imageUploadParam' => 'file',
        'imageUploadURL' => \yii\helpers\Url::to(['site/upload/'])
    ],
    'clientPlugins'=> ['fullscreen', 'paragraph_format', 'image']
]); ?>

For full details on usage, see the documentation.

Custom Buttons Example

The custom Buttons can be defined in JS files anywhere you want, in this example in /basic/assets/ folder.

In the view:

<?php $this->registerJsFile('/basic/assets/alert.js', ['depends' => '\Froala\Editor\FroalaEditorAsset']);?>

<?= \Froala\Editor\FroalaEditorWidget::widget([
    'name'          => 'body',
    'clientOptions' => [
        'toolbarInline'    => false,
        'height'           => 200,
        'theme'            => 'royal',//optional: dark, red, gray, royal
        'language'         => 'en_gb',
        'toolbarButtons'   => ['fullscreen', 'bold', 'italic', 'underline', '|', 'paragraphFormat', 'insertImage', 'alert']
    ],
    'clientPlugins' => ['fullscreen', 'paragraph_format', 'image']
]); ?>

In /basic/assets/alert.js:

FroalaEditor.DefineIcon('alert', {NAME: 'info'});
FroalaEditor.RegisterCommand('alert', {
        title: 'Hello',
        focus: false,
        undo: false,
        refreshAfterCallback: false,
        callback: function () {
            alert('Hello!');
        }
    }
);

For more details you can go to Custom Buttons

License

This package is available under MIT License. However, Froala editor requires purchasing a license from https://www.froala.com/wysiwyg-editor/pricing.

More Repositories

1

design-blocks

A set of 170+ Bootstrap based design blocks ready to be used to create clean modern websites.
HTML
13,506
star
2

wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
CSS
5,259
star
3

angular-froala-wysiwyg

Angular 4, 5, 6, 7, 8 and 9 plugin for Froala WYSIWYG HTML Rich Text Editor.
TypeScript
732
star
4

vue-froala-wysiwyg

Vue component for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
632
star
5

react-froala-wysiwyg

React component for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
562
star
6

wysiwyg-rails

Ruby gem for Froala jQuery WYSIWYG HTML Rich Text Editor.
CSS
465
star
7

angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
306
star
8

django-froala-editor

Package to integrate Froala WYSIWYG HTML rich text editor with Django.
CSS
283
star
9

nova-froala-field

A Laravel Nova Froala WYSIWYG Editor Field.
PHP
113
star
10

react-froala-design-blocks

React implementation for Froala Design Blocks.
JavaScript
108
star
11

KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
PHP
105
star
12

meteor-froala

Meteor bindings for the Froala WYSIWYG HTML Editor.
CSS
68
star
13

ember-froala-editor

Ember component for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
68
star
14

vue-froala-design-blocks

Vue JS implementation for Froala Design Blocks.
Vue
60
star
15

design-framework-demo

CSS
59
star
16

wordpress-froala-wysiwyg

Wordpress plugin for Froala WYSIWYG HTML Editor.
CSS
42
star
17

wysiwyg-editor-php-sdk

PHP SDK to ease the integration of Froala WYSIWYG Editor on server side.
PHP
40
star
18

wysiwyg-editor-release

Froala wysiwyg editor release
HTML
30
star
19

wysiwyg-editor-dotnet-sdk

.NET SDK to ease the integration of Froala WYSIWYG Editor on server side.
JavaScript
29
star
20

aurelia-froala-editor

Aurelia plugin for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
28
star
21

ember-froala

[DEPRECATED] Please use https://github.com/froala/ember-froala-editor instead.
JavaScript
28
star
22

angular-froala-design-blocks

Angular implementation for Froala Design Blocks.
HTML
27
star
23

froala-reactive

A Meteor reactive template wrapper around Froala WYSIWYG HTML Editor.
JavaScript
25
star
24

wysiwyg-editor-node-sdk

Node.JS SDK to ease the integration of Froala WYSIWYG Editor on server side.
JavaScript
25
star
25

froala-pages

HTML
21
star
26

wysiwyg-editor-v1

A flat designed jQuery WYSIWYG Rich Text Editor based on HTML5.
JavaScript
21
star
27

wysiwyg-editor-python-sdk

Python SDK to ease the integration of Froala WYSIWYG Editor on server side.
Python
21
star
28

Craft-3-Froala-WYSIWYG

Craft 3 CMS plugin for Froala WYSIWYG HTML Rich Text Editor.
PHP
16
star
29

Craft-Froala-WYSIWYG

Craft CMS plugin for Froala WYSIWYG HTML Rich Text Editor.
JavaScript
16
star
30

wysiwyg-editor-java-sdk

Java SDK to ease the integration of Froala WYSIWYG Editor on server side.
HTML
15
star
31

editor-php-sdk-example

Example for using the Froala Editor PHP SDK
PHP
11
star
32

wysiwyg-cake2

CakePHP Plugin for Froala Javascript WYSIWYG Rich Text Editor.
CSS
11
star
33

knockout-froala

Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor
Shell
10
star
34

wysiwyg-editor-ruby-sdk

Ruby
9
star
35

wysiwyg-cake

CakePHP Plugin for Froala Javascript WYSIWYG Rich Text Editor.
CSS
8
star
36

editor-ruby-sdk-example

Ruby
7
star
37

vue-froalacharts

Simple and lightweight official Vue component for FroalaCharts.
JavaScript
5
star
38

froala-gatsby

JavaScript
3
star
39

froala-editor-nuget

Nuget package for Froala WYSIWYG Editor
3
star
40

angular-froala-systemjs-demo

A quick starter to use angular-froala with system js
TypeScript
2
star
41

froala-image-uploader-example

Sample PHP application demo for Froala Image Uploader
PHP
2
star
42

froalacharts

JavaScript
2
star
43

.github

1
star
44

react-froalacharts-component

Simple and lightweight official React component for FroalaCharts.
JavaScript
1
star
45

ember-froalacharts

Simple and lightweight official Ember component for FroalaCharts.
JavaScript
1
star
46

xt-themes

JavaScript
1
star