froala / froala/KMSFroalaEditorBundle

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

Open
#134 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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

```yaml
# 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:
```twig
{% if froala_customJS is defined %}

{% endif %}
```

Additionally, as referenced in [Issue #127](https://github.com/froala/KMSFroalaEditorBundle/issues/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:
```twig
{% if froala_customJS is defined %}
{% if froala_customJS is iterable %}
{% for script in froala_customJS %}

{% endfor %}
{% else %}

{% 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.