eckinox / tinymce-bundle

TinyMCE 6 integration for your Symfony apps and forms
MIT License
20 stars 2 forks source link

Strange issue with tinymce_type.html.twig and JavaScriptImportPathCompiler #15

Open devrodor opened 4 months ago

devrodor commented 4 months ago

I've encountered a strange bug, not sure if you've come across it.

I have two projects, one based on Symfony 6.4.1 and another on Symfony 6.4.4.

In the 6.4.1 version, I've installed TinyMCE without any issues using this bundle.

In the 6.4.4 project, I get the following error when integrating TinymceType into the Form Builder:

"An exception has been thrown during the rendering of a template ('Symfony\Component\AssetMapper\Compiler\JavaScriptImportPathCompiler::compile(): Return value must be of type string, null returned') in '@Tinymce/form/tinymce_type.html.twig'."

Upon investigating the problem's source, if I move the TinyMCE folder inside public > bundles and place it in root (public), and modify the twig template 'tinymce_type.html.twig' in this way, everything works correctly.

{%- block tinymce_widget -%}
    <tinymce-editor
        id="{{ id }}"
        name="{{ full_name }}"
        {{ required ? "required" : "" }}
        {{ block('attributes') }}
        src="{{ asset('tinymce/ext/tinymce/tinymce.min.js') }}"
        >{{ value }}</tinymce-editor>
    <script src="{{ asset('tinymce/ext/tinymce-webcomponent.js') }}" type="module"></script>
{%- endblock -%}

Checking vite.config.js, I find no issues.

Moreover, if I modify the previously mentioned template and point to tinymce.js (not to the minimized version), the error disappears, although it does not work. If you need more information, I can provide it for you.

EmilePerron commented 1 month ago

Hey there!

Sorry I didn't get to this earlier, being a new dad and starting a new job leaves me with a bit less free time for open source work than I had before! :p

This bundle hasn't been tested at all with AssetMapper, so with bundling, files may move to different places, be renamed or be merged with other files, so it's very likely to cause issues here.

If you could provide a minimal reproduction of this that I could clone locally and test with, I could very likely get that fixed over the next few days / weeks.

Thanks,