spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
813 stars 256 forks source link

Textarea not showing up #280

Closed afdev82 closed 2 years ago

afdev82 commented 2 years ago

I'm using the e-commerce Solidus v3 on Heroku and also Alchemy CMS v5. For some time I'm having problems with TinyMCE. Before it was only on Alchemy CMS (tinyMCE is included without this gem, but directly minified in the vendor/assets) and now also in Solidus (I'm using an extension to add some content editing and the tinyMCE is included there using this gem).

The problem is that I don't see the textarea field anymore to edit the text in both backends. The field is in the html, but since tinyMCE is used, it doesn't show up. For a millisecond I see the content in the textarea and then it disappears. I tried to find a solution and I could see that the problem is that the Asset Pipeline doesn't compile the files needed for tinyMCE, they are simply empty. If I inspect with the browser console, the response is empty. In the case of Solidus the files are: /assets/tinymce/themes/modern/theme.js

In Alchemy are: /assets/tinymce/plugins/alchemy_link/plugin.min.js /assets/tinymce/skins/alchemy/skin.min.css /assets/tinymce/skins/alchemy/content.min.css

I have another website with a very similar setup without Solidus on a server that I can control. Some time ago I had the same problem and I was using a workaround: I deleted the compiled empty files and re-run the asset pipeline again and they were compiled after that, but in Heroku it's not possible to do that.

The problem is happening only in production, in development all is fine.

I'm using on Heroku: rails (6.0.3.6) alchemy_cms (5.2.1) solidus (3.0.1) tinymce-rails (4.9.11)

On the other server: rails (5.2.6) alchemy_cms (5.2.1)

I don't have any idea how to debug this problem, any help in the right direction will be much appreciated. I have also the CloudFlare CDN in front that maybe complicates more with caching, I don't know. What I saw that the compiled files were empty on the server once published. Thank you!

afdev82 commented 2 years ago

I did some tests locally and I found that the first time when running:

bundle
yarn
bin/rake assets:precompile

After that the files are in the public/assets/tinymce folder and with content. But I found that if I re-run the precompile task, they are there, but empty! All the other assets except the ones of tinymce are ok. It's the same if I run the precompile task in the production environment:

bundle install --without development test
yarn
RAILS_ENV=production bin/rake assets:precompile

After deleting the folder, the files are correctly created. The second time the files are empty.

I have no idea what's happening here. It's strange that I have the problem also on Heroku where AFAIK it should deploy every time in a new location.

afdev82 commented 2 years ago

I solved just removing the solidus_editor extension and with it also the transitive dependency to tinymce-rails gem. So I'm just using the version of tinymce directly included in AlchemyCMS.