Skip to content

Commit 7716aab

Browse files
author
Igor Chepurnoy
committed
remove imperavi editor, added froala editor
1 parent 3f8a159 commit 7716aab

File tree

5 files changed

+19
-40
lines changed

5 files changed

+19
-40
lines changed

Module.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ class Module extends \yii\base\Module
2020
public $defaultRoute = 'manage';
2121

2222
/**
23-
* @var array imperavi editor options
23+
* @var array froala editor options
24+
*
25+
* @see https://www.froala.com/wysiwyg-editor/docs
2426
*/
25-
public $imperaviEditorOptions = [
26-
'plugins' => ['video', 'fullscreen', 'table'],
27-
'options' => [
28-
'minHeight' => 200,
29-
'imageUpload' => '/cms/manage/file-upload',
30-
'fileUpload' => '/cms/manage/file-upload',
27+
public $froalaEditorOptions = [
28+
'clientOptions' => [
29+
'heightMin' => 300,
30+
'theme' => 'gray',
31+
'imageUploadURL' => '/cms/manage/image-upload',
32+
'imageManagerLoadURL' => '/cms/manage/images',
33+
],
34+
'excludedPlugins' => [
35+
'file',
36+
'emoticons',
3137
],
3238
];
3339

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This module provides a web interface for content management system and includes
44

55
- Allows CRUD operations for pages
66
- [Support Markdown Editor](https://github.com/yii2mod/yii2-markdown)
7+
- [Support Froala Editor](https://www.froala.com/wysiwyg-editor)
78
- [Support Comments Management System](https://github.com/yii2mod/yii2-comments)
89
- Integrated with [yii2mod/base](https://github.com/yii2mod/base)
910

Widget.php

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace yii2mod\cms;
44

5+
use froala\froalaeditor\FroalaEditorWidget;
56
use Yii;
6-
use yii\web\JsExpression;
77

88
/**
99
* Class Widget
1010
*
1111
* @package yii2mod\cms
1212
*/
13-
class Widget extends \yii\imperavi\Widget
13+
class Widget extends FroalaEditorWidget
1414
{
1515
/**
1616
* @inheritdoc
@@ -21,33 +21,8 @@ public function init()
2121

2222
$request = Yii::$app->getRequest();
2323

24-
if ($request->enableCsrfValidation && isset($this->options['imageUpload'])) {
25-
$this->options['uploadImageFields'][$request->csrfParam] = $request->getCsrfToken();
26-
$this->options['uploadFileFields'][$request->csrfParam] = $request->getCsrfToken();
27-
}
28-
}
29-
30-
/**
31-
* @inheritdoc
32-
*/
33-
public function run()
34-
{
35-
parent::run();
36-
37-
$this->registerDefaultCallbacks();
38-
}
39-
40-
/**
41-
* Register default callbacks.
42-
*/
43-
protected function registerDefaultCallbacks()
44-
{
45-
if (isset($this->options['imageUpload']) && !isset($this->options['imageUploadErrorCallback'])) {
46-
$this->options['imageUploadErrorCallback'] = new JsExpression('function (response) { alert(response.error); }');
47-
}
48-
49-
if (isset($this->options['fileUpload']) && !isset($this->options['fileUploadErrorCallback'])) {
50-
$this->options['fileUploadErrorCallback'] = new JsExpression('function (response) { alert(response.error); }');
24+
if ($request->enableCsrfValidation) {
25+
$this->clientOptions['imageUploadParams'][$request->csrfParam] = $request->getCsrfToken();
5126
}
5227
}
5328
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"yii2mod/yii2-editable": "*",
2626
"yii2mod/yii2-comments": "*",
2727
"yii2mod/yii2-markdown": "*",
28-
"asofter/yii2-imperavi-redactor": "*",
28+
"froala/yii2-froala-editor": "dev-master",
2929
"cebe/markdown": "~1.1.1",
3030
"yii2tech/ar-file": "*"
3131
},

migrations/m170419_224001_create_attachment_table.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
* Handles the creation of table `attachment`.
7-
* Has foreign keys to the tables:
8-
*
9-
* - `cms`
107
*/
118
class m170419_224001_create_attachment_table extends Migration
129
{

0 commit comments

Comments
 (0)