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

Support for Multiple Custom Plugin Scripts in froala_widget.html.twig #134

Open
DevShaun1 opened this issue Jan 18, 2025 · 0 comments
Open

Comments

@DevShaun1
Copy link

Description

The README suggests that multiple custom plugin and button scripts can be loaded using the customJS option:

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

However, the src/Resources/views/Form/froala_widget.html.twig file currently only accommodates a single string for the froala_customJS variable:

{% if froala_customJS is defined %}
     <script type="text/javascript"  src="{{ asset( customJS ) }}"></script>
{% endif %}

Additionally, as referenced in Issue #127, the correct variable name passed to asset() should be froala_customJS.

Problem

This implementation does not allow for an array of scripts to be passed and iterated through, which limits flexibility for users who need to load multiple scripts.

Suggested Solution

Update the Twig template to handle both a single string and an array of scripts for froala_customJS. The logic should maintain backward compatibility, loading a single script if a string is provided or iterating through an array if multiple scripts are specified. Below is the proposed code update:

{% if froala_customJS is defined %}
    {% if froala_customJS is iterable %}
        {% for script in froala_customJS %}
            <script type="text/javascript" src="{{ asset(script) }}"></script>
        {% endfor %}
    {% else %}
        <script type="text/javascript" src="{{ asset(froala_customJS) }}"></script>
    {% endif %}
{% endif %}

Benefits

  • Supports both single string and array formats for froala_customJS.
  • Maintains backward compatibility with existing implementations.
  • Provides greater flexibility for users to load multiple custom plugins or buttons.
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

No branches or pull requests

1 participant