Giter Site home page Giter Site logo

kmsfroalaeditorbundle's Introduction

KMSFroalaEditorBundle

Package version Build Status Downloads PHP Version Licence

Introduction

This bundle aims to easily integrate & use the Froala editor in Symfony 4.4+/5.0+.

If you want to use it with Symfony < 4.3, see v2 docs. v2.x is compatible with Symfony 2.x to 4.x, but some deprecations are not fixed and static files are integrated to the bundle.

There's also a v3 version available compatible with Symfony 4.3+/5.0+ but the form type options are not prefixed with froala_, which is the major reason for a v4 of the bundle.

The changelogs are available here:

Table of Contents

  1. Migration to Froala Editor bundle v4 from v3
  2. Installation
    1. Step 1: Install the bundle using composer
    2. Step 2: Add the bundle to your bundles.php
    3. Step 3: Import routes
    4. Step 4: Load Twig form widget
    5. Step 5: Configure the bundle
      1. Required
      2. Other options
    6. Step 6: Add Froala to your form
    7. Step 7: Install asset files
    8. Step 8: Display editor content
      1. Manually
      2. Using the Twig extension
    9. Step 9: Profiles (custom configurations)
  3. More configuration
    1. Plugins
    2. Concept: Image upload/manager
    3. Concept: File upload
    4. Concept: Autosave
    5. Webpack Encore configuration
  4. TODO
  5. Licence
  6. Contributing

Migration to Froala Editor bundle v4 from v3

It now supports only Symfony 4.4+ & 5.0+.

If you somehow override/inherit a class from the bundle, be careful as some parameter & return types have been added.

All form type options must now be prefixed by froala_:

// Before
$builder->add('field', FroalaEditorType::class, [
    'toolbarButtons' => [...],
]);

// After
$builder->add('field', FroalaEditorType::class, [
    'froala_toolbarButtons' => [...],
]);

Installation

Step 1: Install the bundle using composer

composer require kms/froala-editor-bundle

Note: if you install the bundle using Symfony Flex & accepted the recipe, you can skip steps 2 to 4.

Step 2: Add the bundle to your bundles.php

// config/bundles.php
return [
    //..
    KMS\FroalaEditorBundle\KMSFroalaEditorBundle::class => ['all' => true],
];

Step 3: Import routes

# config/routes.yaml 
kms_froala_editor:
    resource: '@KMSFroalaEditorBundle/Resources/config/routing.yml'
    prefix:   /froalaeditor

Step 4: Load Twig form widget

# In config/packages/twig.yaml
twig:
    form_themes:
        - '@KMSFroalaEditor/Form/froala_widget.html.twig'

Step 5: Configure the bundle

Required

First, you have to select your language, other settings are optional (see below).

# config/packages/kms_froala_editor.yaml 
kms_froala_editor:
    language: 'nl'

Other options

All Froala options (list provided here) are supported. Just add the option name (prefixed with froala_ if it's in your form type) with your value. If you want to keep Froala default value, don't provide anything in your config file. For options which require an array, provide a value array. For options which require an object, provide a key/value array.

Note that some options need some plugins (all information provided in the Froala documentation).

Example for each option type below:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    toolbarInline: true
    tableColors: [ "#FFFFFF", "#FF0000" ]
    saveParams: { "id" : "myEditorField" }

To provide a better integration with Symfony, some custom options are added, see the full list below:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # Froala licence number if you want to use a purchased licence.
    serialNumber: "XXXX-XXXX-XXXX"

    # Disable CodeMirror inclusion.
    includeCodeMirror: false

    # Disable Font Awesome inclusion.
    includeFontAwesome: false

    # Disable all bundle javascripts inclusion (not concerning CodeMirror).
    # Usage: if you are using Grunt or other and you want to include yourself all scripts. 
    includeJS: false

    # Disable all bundle CSS inclusion (not concerning Font Awesome nor CodeMirror).
    # Usage: if you are using Grunt or other and you want to include yourself all stylesheets. 
    includeCSS: false

    # Change the froala base path.
    # Useful eg. when you load it from your own public directory.
    # Defaults to "/bundles/kmsfroalaeditor/froala_editor"
    basePath: "/my/custom/path".

    # Custom JS file.
    # Usage: add custom plugins/buttons...
    customJS: "/custom/js/path"

Step 6: Add Froala to your form

Just add a Froala type in your form:

use KMS\FroalaEditorBundle\Form\Type\FroalaEditorType;

$builder->add('field', FroalaEditorType::class);

All configuration items can be overridden:

$builder->add('field', FroalaEditorType::class, [
    'froala_language'      => 'fr',
    'froala_toolbarInline' => true,
    'froala_tableColors'   => ['#FFFFFF', '#FF0000'],
    'froala_saveParams'    => ['id' => 'myEditorField'],
]);

Step 7: Install asset files

To install the asset files, there is froala:install command that downloads the last version available of Froala Editor and puts it by default in the vendor/kms/froala-editor-bundle/src/Resources/public/froala_editor/ directory:

bin/console froala:install

There are a few arguments/options available:

  • First (and only) argument (optional): the absolute path where the files will be put after download. Defaults to vendor/kms/froala-editor-bundle/src/Resources/public/froala_editor/.
  • Option tag: the version of Froala that will be installed (eg. v3.0.1). Defaults to master.
  • Option clear (no value expected, disabled by default): Allow the command to clear a previous install if the path already exists.

After you launched the install command, you have to link assets, eg.:

bin/console assets:install --symlink public

Step 8: Display editor content

Manually

To preserve the look of the edited HTML outside of the editor you have to include the following CSS files:

<!-- CSS rules for styling the element inside the editor such as p, h1, h2, etc. -->
<link href="../css/froala_style.min.css" rel="stylesheet" type="text/css" />

Also, you should make sure that you put the edited content inside an element that has the class fr-view:

<div class="fr-view">
    {{ myContentHtml|raw }}
</div>

Using the Twig extension

To use the Twig extension, simply call the display function (note that the front CSS file is not included if the parameter includeCSS is false):

{{ froala_display(myContentHtml) }}

Step 9: Profiles (custom configurations)

You can define several configuration profiles that will be reused in your forms, without repeating these configurations.

When using a profile, the root configuration options will be used & overridden:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    heightMax: 400
    attribution: false
    profiles:
        profile_1:
            heightMax: 500
use KMS\FroalaEditorBundle\Form\Type\FroalaEditorType;

$builder->add('field', FroalaEditorType::class, [
    'froala_profile' => 'profile_1',
]);

In this example, profile_1 profile will have these configuration options set:

  • heightMax: 500
  • attribution: false

More configuration

Plugins

All Froala plugins are enabled, but if you don't need one of them, you can disable some plugins...

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # Disable some plugins.
    pluginsDisabled: [ "save", "fullscreen" ]

... or chose only plugins to enable:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # Enable only some plugins.
    pluginsEnabled: [ "image", "file" ]

Plugins can be enabled/disabled for each Froala instance by passing the same array in the form builder.

Concept: Image upload/manager

This bundle provides an integration of the Froala image upload concept to store your images on your own web server (see custom options for configuration like upload folder).

If you want to use your own uploader, you can override the configuration (if you need to do that, please explain me why to improve the provided uploader).

To provide a better integration with Symfony, some custom options are added, see the full list below:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # The image upload folder in your /web directory.
    # Default: "/upload".
    imageUploadFolder: "/my/upload/folder"

    # The image upload URL base.
    # Usage: if you are using URL rewritting for your assets.
    # Default: same value as provided as folder.
    imageUploadPath: "/my/upload/path"

Concept: File upload

This bundle provides an integration of the Froala file upload concept to store your files on your own web server (see custom options for configuration like upload folder).

If you want to use your own uploader, you can override the configuration (if you need to do that, please explain me why to improve the provided uploader).

To provide a better integration with Symfony, some custom options are added, see the full list below:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # The file upload folder in your /web directory.
    # Default: "/upload".
    fileUploadFolder: "/my/upload/folder"

    # The file upload URL base.
    # Usage: if you are using URL rewritting for your assets.
    # Default: same value as provided as folder.
    fileUploadPath: "/my/upload/path"

    # Your public directory, from the root directory.
    # Default: "/public"
    publicDir: "/home"

Concept: Autosave

The Froala autosave concept to automatically request a save action on your server is working, just enter the correct options in your configuration file:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    saveURL: "my_save_route"
    saveInterval: 2500
    saveParam: "content"

To provide a better integration with Symfony, some custom options are added, see the full list below:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    # Add some parameters to your save URL.
    # Usage: if you need parameters to generate your save action route (see save explaination below).
    # Default: null.
    saveURLParams: { "id" : "myId" }

You can add some parameters in your save route (see custom options).

Webpack Encore configuration

If you want to load Froala asset files using npm/yarn and Webpack Encore, here's how to do it:

import FroalaEditor from 'froala-editor';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';

// Load your languages
import 'froala-editor/js/languages/fr.js';

// Load all plugins, or specific ones
import 'froala-editor/js/plugins.pkgd.min.js';
import 'froala-editor/css/plugins.pkgd.min.css';

window.FroalaEditor = FroalaEditor;

function froalaDisplayError(p_editor, error ) {
    alert(`Error ${error.code}: ${error.message}`);
}

window.froalaDisplayError = froalaDisplayError;

Now you can disable Froala bundle CSS/JS inclusion:

# config/packages/kms_froala_editor.yaml
kms_froala_editor:
    includeJS: false
    includeCSS: false

Don't forget to import the generated Encore CSS/JS files in your HTML if needed.

TODO

  • Add some tests

Licence

This bundle provides an integration of the WYSIWYG Froala Editor commercial version. Please read the Froala licence agreement and go to the pricing page if you don't have a licence.

Contributing

Feel free to contribute, like sending pull requests to add features/tests.

Note there are a few helpers to maintain code quality, that you can run using these commands:

composer cs:dry # Code style check
composer phpstan # Static analysis
vendor/bin/simple-phpunit # Run tests

kmsfroalaeditorbundle's People

Contributors

benatespina avatar dheerajaccolite avatar dianaprajescu avatar fabianfabian avatar gsaulmon avatar jmsche avatar jyothigayathri avatar kapil2704 avatar mpoiriert avatar parashuram-sram avatar sguionni avatar stefanneculai avatar uftimmy avatar vashu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kmsfroalaeditorbundle's Issues

Language has to be configured

Howdy,

The readme says "Step 5 : Configure the bundle (optional)", but this step is not really optional. Language is required, as seen here:

#16 (comment)

So I think the docs should give the minimum required configuration in one section, and then another section about optional configuration.

If you agree, I don't mind updating them.

Thanks!

Themes

It doesn't seem that the theme setting is used appropriately. I'm setting this in the config.yml...

theme: 'gray'

However, no theme changes appear. And no missing css or anything is reported in the console. So I'm thinking that theme key is not being used?

If I add the theme css to the froala_widget.html.twig then it shows just fine.

Am I trying to set the theme incorrectly or was it maybe forgotten?

Add stable tag

Hi, this package hasn't enabled auto-update inside Packagist so, the last merged PR is not referenced yet. Can you update the reference and by the way, can you tag a stable version?

Thanks in advance.

Array keys assumed to be unset are not checked before accessed

// Manage user entries, image has default values (can be set to null by user), but save and parameters has no default values.
$imageManagerDeleteURL = $p_arrOption[ "imageManagerDeleteURL" ];
$imageManagerLoadURL = $p_arrOption[ "imageManagerLoadURL" ];
$imageUploadURL = $p_arrOption[ "imageUploadURL" ];
$fileUploadURL = $p_arrOption[ "fileUploadURL" ];
$videoUploadURL = $p_arrOption[ "videoUploadURL" ];

When I add in config:

kms_froala_editor:
    imageManagerDeleteURL: null

I get

Notice: Undefined index: imageManagerDeleteURL

If I set false

kms_froala_editor:
    imageManagerDeleteURL: false

it works because this check passes

if( $imageManagerDeleteURL != null )

but you may change that check in future releases (for example strict null check !== null) and will break my project.

Please change the checks to something more explicit/clear, so we can understand what values are allowed.

For example that if can be changed to

if( $imageManagerDeleteURL )

Events handling

Currently there is no way to handle events, it would be nice to have an additional options for the type:

$builder->add( "yourField", FroalaEditorType::class , 
    array('froalaEvents' => array('eventName' => 'functionName'))

I've already implemented this on an extension I made for a project but I think it would made a nice addition to the bundle, if you are interested I'd make a pull request.

Configuration for Symfony 3.0.6

I have installed and configured it as given in the instructions, but while adding it to the form as given below, it says Could not load type "froala"

$builder->add( "yourField", "froala" );

Can you specifically tell how to add it in form in Symfony 3, because Symfony 3 requires Type and Class to be included and declared, explicitly like below mentioned example:-

Type:-
use Symfony\Component\Form\Extension\Core\Type\TextType;

and Class-
builder->add('title', TextType::class)

Do we include it from any namespace, as above?
Thanks..

Parsing response failed when uploading image (.NET)

Hello,

I'm having a problem when doing the response parser, in question FROALA gives me the error: "Parsing response failed.", although the object obtained is the following "{"link":"Upload/1695423b.png"} "

The image is correctly uploaded to the server, the path to which the test is referenced in the browser and the image looks correct, but still gives the error What is happening?

I have the latest version of Froala deployed and the browser used is IE11 version 11.0.9600.18893 and ChromeVersion 64.0.3282.186.

Attached screenshots and Word file with the source of both the upload and the file containing FROALA

Best regards !!

Source Code:
CODE.docx

browser

image

OS.

Windows 7 + IIS7

Browser.

IE11 version 11.0.9600.18893 and ChromeVersion 64.0.3282.186.

FroalaEditor doesn't show anything

May I did a mistake in my config ?
I follow all the steps, but nothing appears. Here my config:

config.yml:
kms_froala_editor: language: "fr"

My ArticleType.php:
use KMS\FroalaEditorBundle\Form\Type\FroalaEditorType;

class ArticleType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', TextType::class, array('label'=>'Titre',
'required'=>false,
'attr'=>['class'=>'form-control']))
->add('main', FroalaEditorType::class, array('label'=>'Texte'))
->add('Validez', SubmitType::class)
}

I added these links in my layout:

in the header and <script src="{{ asset('bundles/framework/js/froala_editor.pkgd.min.js') }}"></script> in my js_block

All the assets are installed in the vendor and in the web bundles.

Any idea please ? Thanks for your help.

do not delete file option [suggestion]

I would like to have an option in this bundle to disable the fact that an image file is deleted from the file system when the image is deleted from the wysiwyg.

What do you think about that ?

Iphone : click on Picture upload not working

Hello,

There is a bug with the new version (v2.4.2) where you can't click on the "upload image" button on Iphone. The image upload popup closes and nothing happen.

If I click on the toolbar just on top of the input and then click the input it works. Maybe an error of CSS ? Tried some z-index all around the place but nothing fixed it.

Iphone 6 (ios 10.2) on Safari and Chrome. Tried with multiple devices (ios bug, android ok).

Make bundle compatible with symfony 2.6

The bundle requires a version of symfony lower than 2.6.

Does anything need to happen to make it compatible or can you just bump the requirement in composer.json?

Plugins Issues

Hi !

Great work for the plugin, works like a charm.
I still got a problem, i found the way to display buttons in my toolbar but i can't use it. I mean when i click on the "colors" button for example, nothing's happening. I included all the js and css files following the good practices, but it still doesn't work.

I'm working with Symfony 3.2.9. I have to let it go for few days because i got other missions, but if anyone could help me it would be really kind =)

Mathieu.

Unlicensed Froala Editor

After installing you bundle I'm getting this error instead of an editor. I'm not setting serialNumber in config.
Is there something wrong with my installation?

Can be used this bundle as a WYSIWYG for Twig Templates?

I will start developing a functionality for the application I am working on and I need to give the users the ability to edit templates (.html.twig files) on the fly. Think for example in a few email templates where the users would like to add some images, text, copyright and also dynamic content. Can this be done with this bundle? Can I take a template and let the user edit it and save it afterwards?

[bug] Upload image on my server, Error 4 : Parsing response failed

Hi,
When i want upload an image in froala editor i have this error :

image

Error log :

image

My code :

JS

$('.froala-editor').froalaEditor({
    toolbarButtons: ['fullscreen', 'undo', 'redo', '|',
        'bold', 'italic', 'underline', '|',
        'fontFamily', 'fontSize', 'color', 'emoticons', 'insertHR', 'clearFormatting', '|',
        'paragraphFormat', 'paragraphStyle', 'quote', 'align', 'formatOL', 'formatUL', 'outdent', 'indent', '|',
        'insertLink', 'insertImage', 'insertVideo', 'insertTable', '|',
        'html', 'help'
    ],

    saveURL: Routing.generate('admin_upload_image'),

    // Set the image upload URL.
    imageUploadURL: Routing.generate('admin_upload_image'),

    // Additional upload params.
    imageUploadParams: {id: 'my_editor'},

    // Set request type.
    imageUploadMethod: 'POST',

    // Set max image size to 5MB.
    imageMaxSize: 5 * 1024 * 1024,

    // Allow to upload PNG and JPG.
    imageAllowedTypes: ['jpeg', 'jpg', 'png']

}).on('froalaEditor.image.beforeUpload', function (e, editor, images) {
    // Return false if you want to stop the image upload.
    })
    .on('froalaEditor.image.uploaded', function (e, editor, response) {
        // Image was uploaded to the server.

        console.log(uploadUrl, uploadParam, uploadParams);
        console.log('Image uploaded');
        console.log(e);
        console.log(editor);
        console.log(response);
    })
    .on('froalaEditor.image.inserted', function (e, editor, $img, response) {
        // Image was inserted in the editor.
        console.log('Image inserted');
        console.log(e);
        console.log(editor);
        console.log($img);
        console.log(response);
    })
    .on('froalaEditor.image.replaced', function (e, editor, $img, response) {
        // Image was replaced in the editor.
    })
    .on('froalaEditor.image.error', function (e, editor, error, response) {
        console.log('Image error');
        console.log(e);
        console.log(editor);
        console.log(error);
        console.log(response);
    })
;

Upload function:

 /**
     * @Route("/uploadImage", name="admin_upload_image", options={"expose": true})
     * @Method({"GET", "POST"})
     * @param Request $request
     * @return JsonResponse
     */
    public function uploadImageAction(Request $request)
    {
        $mediaManager = $this->get("kms_froala_editor.media_manager");
        $path         = $request->request->get("path");
        $folder       = $request->request->get("folder") . '/upload';
        $rootDir      = $this->get("kernel")->getRootDir();
        $basePath     = $request->getBasePath() . '/upload';

        return $mediaManager->uploadImage($request->files, $rootDir, $basePath, $folder, $path);

    }

What could be the problem?

An exception has been thrown during the rendering of a template

In Symfony4 editor is not working:

An exception has been thrown during the rendering of a template ("The "templating.helper.assets" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.").

{{ froala_display(form.content) }}

Profiles

It would be useful to have the possibility to manage different configuration profiles and then using them by specifying a "profile" option on the Type.

something like:

kms_froala_editor:
    profiles:
        profile1:
            tableColors: [ "#FFFFFF", "#FF0000" ]
        profile2:
            tableColors: [ "#FFFF00", "#FF0000" ]

and then applying it with

$builder->add( "yourField", FroalaEditorType::class , array('profile' => 'profile1');

If you agree with the feature I could provide a pull request for the implementation.

2.8.1 version bug

Hi,
I got a bug with the 2.8.1 version because the default configuration for basePath is referencing the old 2.7.5 assets version.

To fix this, change the basePath config to "/bundles/kmsfroalaeditor/froala_editor_2.8.1"

Support for EasyAdminBundle

I have been liking the EasyAdminBundle for quickly setting up an admin with crud operations. They have instructions for adding ckeditor, but Froala is far superior.

https://github.com/javiereguiluz/EasyAdminBundle

This is a feature request, unless this can already be done and I'm just failing, to be able to add Froala integration with forms generated by EasyAdminBundle.

composer

hello, I have check this repository and findout that I can't update composer. please check it and help me for setup this repository on my system.

Error 1 : Bad link - Changing imageUploadFolder to /upload/anotherfolder

Hi there,

I just changed imageUploadFolder:

->add('content', 'froala', array(
'mapped' => false,
'data' => $this->data,
'inlineMode' => false,
"imageUploadFolder" => "/upload/cliente2"
));

And the editor give me an alert with the message: Error 1 : Bad link.

Anyone know what can be this?

Image Manager - Any way to restrict to the owner only ?

Hello !

The Image Manager plugin is pretty cool, but all users have acces to everyone uploads...
Can't really use that in production, because I use Froala in my admin area and in the front too for logged users.

Do you have any idea on how to restrict listing to user's only uploads ?

Thank you !

Avairy Key integration failed.

Hi.
My i cannot integrate advanced edit into editor.I added my aviary api key and the script tag into this file in symfony: symfony/KMSFroalaEditorBundle/blob/master/Resources/views/Form/froala_widget.html.twig.
Script tag is
<script type="text/javascript" src="{{ asset( basePath ~ 'js/third_party/image_aviary.min.js' ) }}"></script>
I added button "aviary" to the editor also.
'imageReplace', 'imageAlign', 'imageRemove', '|', 'imageLink', 'linkOpen', 'linkEdit', 'linkRemove', '-', 'imageDisplay', 'imageStyle', 'imageAlt', 'imageSize','aviary']

I got the aviary api key from https://console.adobe.io/ for development.(I did not send it for approve.)
Why this aviary integration does not work?
I am glad if anyone can help.
Thanks

Uncaught ReferenceError: $ is not defined

I'm using Symfony 4 & Webpack. Installed per instructions and am getting the above error in the browser's console. The following statement is throwing the error:

<script type="text/javascript">

				$( document ).ready( function () { $( "#field_name" ).froalaEditor({

kms_froala_editor.yaml:

kms_froala_editor:
    language: "en"
    toolbarInline: true
    tableColors: [ "#FFFFFF", "#FF0000" ]
    saveParams: { "id" : "myEditorField" }    
    includeJQuery: false
    includeCodeMirror: false
    includeFontAwesome: false
    includeJS: false
    includeCSS: false

My layout.js that includes the required js:

...
'use strict';

import $ from 'jquery';
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css';
import 'font-awesome/css/font-awesome.css';
import '../css/main.scss';
...

A quick scan of the page shows that all javascript files that are required (jquery & froala) are being included. I suspect it's an issue of "$( document ).ready" being called.

At any rate, at present am unable to use wysiwyg editor. Any help would be appreciated.

Integrate Froala with Sonata

Hey

I am used Froala Editor with Sonata Admin

$formMapper->add('content', 'froala');

And I have this exception :

Impossible to access an attribute ("options") on a null variable in SonataAdminBundle:Form:form_admin_fields.html.twig at line 326

Using KMSFroala with BeSimple/i18n bundle

Hello,

When I am using Froala with i18n bundle I have this error:

Catchable Fatal Error: Argument 1 passed to KMS\FroalaEditorBundle\Service\OptionManager::__construct() must be an instance of Symfony\Component\Routing\Router, instance of BeSimple\I18nRoutingBundle\Routing\Router given

That is because your OptionManager service expect a Symfony Router object in the constructor. Is it possible to change it to expect a RouterInterface so it will match the cases where people use tierce Router ?

Would then be:

public function __construct( RouterInterface $p_router )

Instead of:

public function __construct( Router $p_router )

Thanks

Upload to S3 with Symfony

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 !

Events don't trigger on popup windows.

Symfony 4

Expected behavior.

Popup windows should close when close button is pressed.
Image manager should select and load the image when it is selected.

Actual behavior.

The close button and the image manager are not working properly when a component is clicked [the component's event is not triggered]

screen shot 2018-04-25 at 1 29 59 pm

Steps to reproduce the problem.

Install KMSFroalaEditorBundle.

https://github.com/froala/KMSFroalaEditorBundle
Steps: 1,2,3,4,5

Configure services.yml

Form type.

kms_froala_editor.form.type:
    class: "KMS\\FroalaEditorBundle\\Form\\Type\\FroalaEditorType"
    arguments: [ "@kernel", "@service_container", "@kms_froala_editor.option_manager", 
    "@kms_froala_editor.plugin_provider" ]
    tags:
        - { name: "form.type", alias: "froala" }

Option provider.

kms_froala_editor.option_manager:
    class: "KMS\\FroalaEditorBundle\\Service\\OptionManager"
    arguments: [ "@router" ]

Plugin provider.

kms_froala_editor.plugin_provider:
    class: "KMS\\FroalaEditorBundle\\Service\\PluginProvider"

Media manager.

kms_froala_editor.media_manager:
    public: true
    class: "KMS\\FroalaEditorBundle\\Service\\MediaManager"

Twig extension.

kms_froala_editor.froala_extension:
    class: "KMS\\FroalaEditorBundle\\Twig\\FroalaExtension"
    arguments: [ "@service_container" ]
    tags:
        - { name: twig.extension }

On a class form write

->add('content', FroalaEditorType::class, array(
       'language' => 'es',
       'label' => false,
       'required' => true,
))

then when the editor is loaded events should not be triggered when a component is clicked on popup windows.

OS.

MacOs Sierra 10.13.4

Browser.

Chrome 66.0.3359.117 (Official Build) (64-bit)

Upload - Symfony 4 - The "kms_froala_editor.media_manager" service or alias has been removed or inlined when the container was compiled.

Hello !

When trying to upload a file, the routes for file management seems to be broken.
Here is the error message :

The "kms_froala_editor.media_manager" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

The "kms_froala_editor.media_manager" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

  at vendor\symfony\dependency-injection\Container.php:259
  at Symfony\Component\DependencyInjection\Container->get('kms_froala_editor.media_manager')
     (vendor\symfony\framework-bundle\Controller\ControllerTrait.php:61)
  at Symfony\Bundle\FrameworkBundle\Controller\Controller->get('kms_froala_editor.media_manager')
     (vendor\kms\froala-editor-bundle\Controller\MediaController.php:28)
  at KMS\FroalaEditorBundle\Controller\MediaController->uploadImageAction(object(Request))
     (vendor\symfony\http-kernel\HttpKernel.php:149)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor\symfony\http-kernel\HttpKernel.php:66)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor\symfony\http-kernel\Kernel.php:190)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public\index.php:37)```

I'm using Symfony 4.0

Thank you for you help !

Disabling Autosave not working

Setting the config parameter for 'saveInterval' to 0 (zero) is not disabling autosave as it should according to the Froala Editor docs.

https://www.froala.com/wysiwyg-editor/docs/options#saveInterval

I noticed this after implementing the image and file upload concepts, that invoking those tools was causing the autosave to attempt to occur, then resulting in the alert message "The saveURL is not defined." I do not have the saveURL defined because I don't want to perform autosave.

Weird bug with toolbarInline enabled on Firefox

I found a weird bug only viewable on Firefox. The toolbar is loaded only with basic options (bold, italic, font). BUT, when i open the "Web Developper" menu, the full toolbar appears.

This bug is only on Firefox.

I don't know if this bug is directly in Froala, or in this Bundle (or only with me).

Froala initialization in form

Hi,

in the file froala widget: https://github.com/froala/KMSFroalaEditorBundle/blob/master/Resources/views/Form/froala_widget.html.twig

You use $(document).ready to delay the execution of the JS till the page is fully loaded.
You should use something in vanilla js to prevent an error from the users that dont include jquery with froala and have their js block at the end of their template.

document.addEventListener("DOMContentLoaded", function() {
// code...
});

or for IE8 and olders browsers:

document.attachEvent("onreadystatechange", function(){
if (document.readyState === "complete"){
document.detachEvent( "onreadystatechange", arguments.callee );
// code ...
}
});

Icon plugin d'ont show

i have 2.3 version and the icon for the plugin code view it's not in the toolbar , i have the see de css and js file .

font-awsome.min.css over http

There is a problem with loading this css file. If your server doesn't allow http connections (just https), it wont be loaded. For some reason, only this file is loaded over http (unlike codemirror.min.css which is loaded over https.

I solved the problem adding by https link to this css file in my element, but it should still be fixed in the framework itself.

Dependency Injection not working for the FormType (Symfony 4)

When trying to add this type as a field to my form it says that o arguments were passed and the constructor was expecting 4 in FroalaEditorType class. My Symfony version is 4. What are the exact steps to set this up with Symfony 4?
Thanks for your time.

Upgrade help

Hi,

I'm wondering how I can help to upgrade the frontend files? Some upgrade process I can reproduce and then send some PR?

Something like this? :

  • Remove froala_editor_x.y.z directory in Resources/public
  • Add new files in Resources/public/froala_editor_a.b.c
  • Update $OPTIONS_STRING_CUSTOM::basePath in Utility/UConfiguration.php

Drop Symfony 2 support?

Hi,

I'm wondering if Symfony 2 support should be dropped or not, as maintaining it becomes harder and harder - especially if support is for 2.3+.

Eg. Symfony 4.1 throws deprecations for the routing controller format - should be KMS\FroalaEditorBundle\Controller\MediaController::uploadImageAction instead of KMSFroalaEditorBundle:Media:uploadImage.
If I'm not wrong, this notation is available for 2.8 but not 2.3, so the fix would be hard to apply.

WDYT?

Image Browser is not displayed

capture d ecran 2016-06-02 a 16 42 10

Im loading all the plugins but the image browser is not displayed. Any idea ? (im using dev-master)
image_manager.min.js is loaded and so is image_manager.min.css

[Help Needed] How to provide dynamic ID for auto-save usage

Hey guys,

I've have several instances of froala editor through the site, so I need to different them by ID for auto-save feature.

So how do I do it?

From documentation,

kms_froala_editor:
  saveParams: { "id" : "myEditorField" }

but what's that suppose to mean? It will send some div contents with auto-save data or what?
I've tried to put js function into it, css id, whatever, it's just send text value back to me, so in my experience saveURLParams and saveParams are non-dynamic and therefore useless.

Do I miss something? Is there some magic word combination, that will allow to put JS function in bundle configuration?

Really lost with this feature, any help is appreciated.

Incompatible jquery Version

Hi! I'm having a trouble with Froala Editor in Sonata Admin.

I'm using datetime type and other fields, when I activate the Jquery inclusion in Froala config, the other fields don't work.

If I desactivate the jQuery inclusion the other fields work, but the froala type works unexpectedly

Here all is appearelly ok

image

but when I clic inside the textarea, the toolbar changes

image

How can I fix this jQuery conflict?

$(...).froalaEditor is not a function

Hi
Just installed your bundle. I've add configuration, add froala to form (a form field type). And have error $(...).froalaEditor is not a function.
froala_editor.min.js loaded also. What could be the problem?

can't change language

hello,

I can't switch language. It stays to default language. Here's my config.yml :

kms_froala_editor:
    language: 'es'

my forms :

...
        ->add("content", FroalaEditorType::class, [
                    "language" => "es",
        ])

I've tried to clear cache, it 's still in english
Can you help me ?

Symfony 3.3.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.