froala / KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
105 stars 33 forks source link

Upload to S3 with Symfony #25

Closed oukaria closed 7 years ago

oukaria commented 7 years ago

Hello,

I am implementing Amazon S3 on my project and while Froala supposed to be working with S3, I can't get it to work on this symfony Bundle.

Where should I put the backend generated response from the FroalaEditor/S3 client ? I tried to put in in the FormType like

$froalaHash = S3::getHash($this->froalaConfig);
$builder->add('description', 'froala', ["label" => "editor","imageUploadToS3" => $froalaHash])

But it bug because of "convert object to string". Tried to put a json_encore but it's not interpreted by the template.


I then tried to add the "imageUploadToS3" to the Javascript object but apparently I can't get the object to just change this propriety, it would require to redo the call on my end, therefor loosing the meaning of the Bundle.

After trying few things on the template "vendor/kms/froala-editor-bundle/Resources/views/Form/froala_widget.html.twig" I came to this :

Replace

{% if value is iterable %}{{ option }} :

by

{% if option == 'imageUploadToS3' %}
     {{ option }} : JSON.parse('{{ value|json_encode|raw }}'),
{% elseif value is iterable %}{{ option }} :

It's nowhere near a clean code but at least it's recognized by the Froala.

Is there a way of making it work right now without changing the code of the Bundle ? I may also be very far off the way of doing it ^^', If so please help me !

sguionni commented 7 years ago

Hello,

indead there are problems with complex objects. I have to check another way to display it in Twig, JSON is not a bad idea, i'll do some tests.

sguionni commented 7 years ago

Hi, just pushed an update to manage array/object option by a better way. Let me know if your issue is solved.