spohlenz / tinymce-rails

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

Upgraded tinymce-rails from 5.2 to 6.4.2 and default silver theme is not working #301

Closed tsankaste closed 1 year ago

tsankaste commented 1 year ago

I am using rails 6.1.7.3 and tried to upgrade tinymce-rails from 5.2.0 to 6.4.2.

With tinymce-rails 5.2.0 I was linking the asset in my manifest.js file: //= link tinymce-jquery.js

But after upgrading to 6.4.2 it tells me the file could not be found:

couldn't find file 'tinymce-jquery.js'
Checked in these paths: 
  /home/.../app/assets/builds
  /home/.../app/assets/config
  /home/.../app/assets/fonts
  /home/.../app/assets/images
  /home/.../app/assets/javascripts
  /home/.../app/assets/stylesheets
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-langs-6.20220429/vendor/assets/config
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-langs-6.20220429/vendor/assets/javascripts
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-6.4.2/app/assets/javascripts
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-6.4.2/app/assets/source
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-6.4.2/vendor/assets/config
  /home/.../.rvm/gems/ruby-3.1.4/gems/tinymce-rails-6.4.2/vendor/assets/javascripts
  /home/.../.rvm/gems/ruby-3.1.4/gems/actionview-6.1.7.3/lib/assets/compiled`

I removed the line from my manifest and included tinymce_assets directly in my view file: = tinymce_assets

<script type="text/javascript">
    tinyMCE.init({
      selector: "textarea.tinymce",
      width: "800",
      height: "400",
      plugins: "preview, table, paste, image, link, media, searchreplace",
      dialog_type: "modal",
      resize: "both",
      toolbar1: "fontselect, fontsizeselect",
      toolbar2: "cut, copy, paste, pastetext, pasteword | bullist, numlist | outdent, indent, blockquote | undo, redo | link, unlink, anchor, cleanup, help, code | preview | forecolor, backcolor | image",
      toolbar3: "tablecontrols",
      extended_valid_elements: "iframe[src|width|height|name|align]"
    });
</script>

tinymce_error tinymce_error1

The theme.js file says it has version 5.10.2 and it seems to me the toolbar errors and 'TypeError: n.ui.isDisabled is not a function' come from this.

Faq commented 1 year ago

Try first migrate to latest 5.x, that would be 5.10.7 and if all works then 6.1. Step by step. And with rails 6.1 using Sprockets 4? Project is publicly available, so can check it out?

spohlenz commented 1 year ago

Check that you don't have any precompiled assets in public/assets.

You may also need to clear your Sprockets cache:

bundle exec rake tmp:clear:cache
tsankaste commented 1 year ago

On the second attempt clearing the cache and removing everything in app/assets/builds did the job. Hopefully it goes well in production as well. Thank you!