spohlenz / tinymce-rails

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

Failed to load content css: http://myurl/assets/tinymce/skins/lightgray/content.min.css now and then #224

Open vinloren opened 7 years ago

vinloren commented 7 years ago

I recently installed this gem into my site's bundle (rails 4.2.8) following the available instructions. The gem works fine most of the times but now and then it is apparently failing in loading the skins/lightgray/content.min.css. In such a case the input area doesn't accept any input (nor the cursor appears) and to recover from this situation a page reload is required.

The strange thing is that if I watch the browser's debug console the apparently failing url did actually load correctly even when the error message is displayed on the screen. Moreover, if I pick up the 'failing url' and try it on another window, the content.min.css shows up correctly at the screen.

I can't understand the reason of such a behaviour so I need some hint / advice to overcome this sticky situation.

vinloren commented 7 years ago

Now I can better explain what's actually going on.

1) the problem shows up in Firefox v.53, if I use Chrome everything works fine

2) I am using tinyMCE in three distinct forms: one for new articles, one for editing, one for comments.

3) If I insert a few new articles no problem appears, the problem shows up just chenging the form in use: i.e. after insertion an article I try editing it or another one or else I try to insert a comment after havine inserted a new article. After the error message has shown I can always recover by reloading the page and no error appears eventually.

I guess there is some caching problem specifically in Firefox since all works fine in Chrome. I will try Windows Edge too..

vinloren commented 7 years ago

Just to complete my checks, I tried using Microsoft Edge in win10 insider build 16193: everything works fine.

vinloren commented 7 years ago

A few days ago I opened bug 1371910 at https://bugzilla.mozilla.org/show_bug.cgi?id=1371910#c5 against this problem and the result was: QUOTE Hi Vincenzo, Thanks for sending us the link. Unfortunately this seems to be a problem with tinyMCE rather than Firefox. The initial load of content.min.css works correctly, and no other attempts to reload it seem to be made. If it works in other browsers it is probably due to the developers doing things differently.

If you still think this is a bug in Firefox, please reopen this bug, and send us a smaller test case.

PS. Others seem to be having the same problem as you: https://community.tinymce.com/communityQuestion?id=90661000000Qct9AAC I hope you find a way to fix it. UNQUOTE

What the Firefox support says makes sense since I too whatched the content.min.css file was actually loaded by the browser so it must be tinyMCE to misinterpret something. Anyway I am still in the soup... Whoever might have some interest at this issue please hava a look at: http://vinloren-learn-rails.herokuapp.com/articles accessing this endpoint with Firefox v52..v54 the click show any article then going back via the 'back' link at the end of the article's content.

frenkel commented 6 years ago

What happens if you disable Turbolinks?

jtrost commented 6 years ago

See: tinymce/tinymce#3763

frenkel commented 6 years ago

Upstream has just released a version with fix: https://github.com/tinymce/tinymce/issues/3763#issuecomment-326244579 Would be great if the gem can also get this updated version.

spohlenz commented 6 years ago

@frenkel tinymce-rails 4.6.6 was released earlier. Can you confirm if that version solves the issue for you?

frenkel commented 6 years ago

@spohlenz Great, thanks. The message is gone, but unfortunate we now see empty TinyMCE editors instead of the actual content. I've asked upstream whether more users have this, maybe this is just a bug in my code.

rohitsiddha commented 6 years ago

@spohlenz and @frenkel , I'm facing the same issue using version 4.6.6. The content load error message is resolved. However editors are blank instead of actual content. Is there any workaround to fix it ? This issue appears only in Firefox

Borzik commented 6 years ago

It looks like I've found the way to fix blank editor on 4.6.6: try to initialize tinyMCE manually instead of just inserting tinymce helper. Here's an example code:

document.addEventListener('turbolinks:load', function(){
  tinyMCE.init(#{tinymce_configuration(:default).to_javascript.gsub(/^/, ' ' * 12).sub(/\A\s+/, "")});
});

I believe the reason is that while page is loading via Turbolinks, it still references tinyMCE from previous page, and the script tinymce helper uses does not wait for page load.