Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yii2 Froala Plugin, Update in accordance with Froala PHP SDK #20

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

puneet0191
Copy link

This PR focuses on changes that would add a default controller to the plugin so we can perform actions like imageUploadURL by using Froala's PHP SDK, load it through the yii routes, unlike before where we had to write a custom Controller uploadAction and Model changes, all we need is to setup a module configuration inside web.php config array and then the upload folder path could be fetched from that.


Either run

```
php composer.phar require --prefer-dist froala/yii2-froala-editor
php composer.phar require --prefer-dist froala/wysiwyg-editor-php-sdk
php composer.phar require --prefer-dist bower-asset/froala-wysiwyg-editor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a composer package as well: https://packagist.org/packages/froala/wysiwyg-editor.

"froala/yii2-froala-editor": "^2.6.0"
"froala/yii2-froala-editor": "^2.6.0",
"froala/wysiwyg-editor-php-sdk" : "*",
"bower-asset/froala-wysiwyg-editor": "^2.6.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, there is a compose package: https://packagist.org/packages/froala/wysiwyg-editor.

README.md Outdated
@@ -132,8 +93,7 @@ For the view:
'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/'])
'imageUploadParam' => 'file'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be required.

composer.json Outdated
"rmrevin/yii2-fontawesome": "^2.0"
"rmrevin/yii2-fontawesome": "^2.0",
"froala/wysiwyg-editor-php-sdk": "*",
"bower-asset/froala-wysiwyg-editor": "^2.6.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the composer package.

src/Module.php Outdated
@@ -0,0 +1,13 @@
<?php

namespace froala\froalaeditor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's user Froala\Editor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understand this change, do you want something like this?

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be better to use Froala\Editor instead of froala\froalaeditor.

{
// Store the image.
try {
$uploadFolder = $this->module->uploadFolder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 4 spaces indentation.

class DefaultController extends Controller
{
// Without false it will give "Bad Request (#400) Unable to verify your data submission."
public $enableCsrfValidation = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set CSRF and pass it along with imageUploadParams?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or through the requestHeaders option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants