spohlenz / tinymce-rails

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

Compiled JS file is empty #258

Closed ianrandmckenzie closed 4 years ago

ianrandmckenzie commented 4 years ago

My Rails application.js has tried both //=require tinymce as well as //=require tinymce-jquery and the files loaded are completely empty. Did the new version not get copied over properly? I'm on TinyMCE version 5.0.13.

ianrandmckenzie commented 4 years ago

I also tried 5.0.12 and 5.0.10 and the JS files are empty as well.

Also tried setting both config.tinymce.install = :copy and config.tinymce.install = :compile in my application.rb.

Also tried using <%= tinymce_assets %> in my view.

ianrandmckenzie commented 4 years ago

Okay, I think I found the problem. The editor wasn't loading properly because I was using <%= tinymce :alternate %> — when I use <%= tinymce %>, it works just fine. Is there something wrong with my configuration?

default:
  plugins:
    - image
    - link

alternate:
  <<: *default
  selector: textarea.table-editor
  toolbar: styleselect | bold italic | undo redo | table
  plugins:
    - table

It's a straight up copy/paste from the README.

Edit: I had to comment out <<: *default because it was giving the error:

Unknown alias: default
ianrandmckenzie commented 4 years ago

If I change the config/tinymce.yml to:

default: &default
  plugins:
    - image
    - link

alternate:
  <<: *default
  selector: textarea.table-editor
  toolbar: styleselect | bold italic | undo redo | table
  plugins:
    - table

I no longer get an error when loading <%= tinymce %> or <%= tinymce :alternate %>, however, when I do :alternate the editor interface does not load at all.

Is there perhaps an interaction with my Ruby/Rails versions? I'm on Ruby 2.6.3 and Rails 6.0.0.rc1

ianrandmckenzie commented 4 years ago

I finally got :alternate to work after remove all of that default stuff in the config/tinymce.yml. This is what it looks like now:

default:
  plugins:
    - image
    - link

alternate:
  plugins:
    - image
    - link
    - table
ianrandmckenzie commented 4 years ago

Another possible issue is that I didn't know what selector did, so :alternate was loading, but I didn't know it, because it was trying to load in an element with the table-editor class.

selector: textarea.table-editor

All in all, the tinymce.yml example made for a very confusing onboarding experience. Perhaps the example could be changed?