PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
149 stars 154 forks source link

tinymce editor disappears when specifying plugin in application.js #62

Closed bobbyworx closed 9 years ago

bobbyworx commented 9 years ago

Hi, my tinymce editor seems to disappear with this setup. What am I doing wrong?

    tinyMCE.init({
      selector: "textarea.tinymce",
      menubar : false,
      theme : "modern",
      plugins: "uploadimage"
    });```

view:

<%= f.text_area :description, :class => "tinymce", :rows => 4, :cols => 100 %>
Thanks!
PerfectlyNormal commented 9 years ago

No idea. Do you get any errors in the web console?

When you say 'disappear', do you mean the entire editor disappears, and you get a regular textarea?

bobbyworx commented 9 years ago

Disappears as in no field is displayed, not event a regular text field.. I am using tinymce-rails (4.1.3)

rasool-sb commented 9 years ago

Hi, For disappearing the tinymce, there would be several reasons, for example, mistype, not installed the plugin properly or forget to remove the plugin after uninstalling, @bobbyworx in your case.., you are using third latest version of tinymce, for this version.. no need to execute this code.. tinyMCE.init({ selector: "textarea.tinymce", menubar : false, theme : "modern", plugins: "uploadimage" });``` by the way where did you mentioned this code ?? in your application.js ?? have you created tinymce.yml file in your "config" directory ?? if you have created tinymce.yml then no need to mention the above code in application.js file., Please check the plugins are correctly mention in the tinymce.yml as well as in the above code..!!

bobbyworx commented 9 years ago

okay, I created a tinymce.yml file under config directory with the following code:

theme: "modern" toolbar1: bold italic | link uploadimage | undo redo | fontselect | forecolor | code | plugins:

view:

<%= f.text_area :offer_greeting, :value => offer_settings(@offer, :offer_greeting), :class => "tinymce", :rows => 4, :cols => 120 %>

Problem is now, tinymce does not load at all. I am seeing only the default text_area.

On Wed, Oct 1, 2014 at 6:09 PM, Rasool.SB notifications@github.com wrote:

Hi, For disappearing the tinymce, there would be several reasons, for example, mistype, not installed the plugin properly or forget to remove the plugin after uninstalling, @bobbyworx https://github.com/bobbyworx in your case.., you are using third latest version of tinymce, for this version.. no need to execute this code.. tinyMCE.init({ selector: "textarea.tinymce", menubar : false, theme : "modern", plugins: "uploadimage" });``` by the way where did you mentioned this code ?? in your application.js ?? have you created tinymce.yml file in your "config" directory ?? if you have created tinymce.yml then no need to mention the above code in application.js file., Please check the plugins are correctly mention in the tinymce.yml as well as in the above code..!!

— Reply to this email directly or view it on GitHub https://github.com/PerfectlyNormal/tinymce-rails-imageupload/issues/62#issuecomment-57479305 .

Bogdan Popa

bobbyworx commented 9 years ago

<textarea class=​"tinymce" cols=​"120" id=​"offer_offer_greeting" name=​"offer[offer_greeting]​" rows=​"4">​​

this shows on inspecting the text area

On Thu, Oct 2, 2014 at 10:13 AM, Bogdan Popa bogdan.popa.a@gmail.com wrote:

okay, I created a tinymce.yml file under config directory with the following code:

theme: "modern" toolbar1: bold italic | link uploadimage | undo redo | fontselect | forecolor | code | plugins:

  • uploadimage

view:

<%= f.text_area :offer_greeting, :value => offer_settings(@offer, :offer_greeting), :class => "tinymce", :rows => 4, :cols => 120 %>

Problem is now, tinymce does not load at all. I am seeing only the default text_area.

On Wed, Oct 1, 2014 at 6:09 PM, Rasool.SB notifications@github.com wrote:

Hi, For disappearing the tinymce, there would be several reasons, for example, mistype, not installed the plugin properly or forget to remove the plugin after uninstalling, @bobbyworx https://github.com/bobbyworx in your case.., you are using third latest version of tinymce, for this version.. no need to execute this code.. tinyMCE.init({ selector: "textarea.tinymce", menubar : false, theme : "modern", plugins: "uploadimage" });``` by the way where did you mentioned this code ?? in your application.js ?? have you created tinymce.yml file in your "config" directory ?? if you have created tinymce.yml then no need to mention the above code in application.js file., Please check the plugins are correctly mention in the tinymce.yml as well as in the above code..!!

— Reply to this email directly or view it on GitHub https://github.com/PerfectlyNormal/tinymce-rails-imageupload/issues/62#issuecomment-57479305 .

Bogdan Popa

Bogdan Popa

PerfectlyNormal commented 9 years ago

Are you using Chrome? If so, what does the Console say? (View -> Developer -> JavaScript Console)

PerfectlyNormal commented 9 years ago

Also, does it work with the same configuration, but without uploadimage in the plugin list or in the toolbar?

bobbyworx commented 9 years ago

no, it does not.. I get 304 not modified from the console. Also, if it helps, this is how my partial looks like:

<%= tinymce_assets %>
...
<%= f.text_area :offer_greeting, :value => offer_settings(@offer, :offer_greeting), :class => "tinymce", :rows => 4, :cols => 120 %></br>
...
<% tinymce %>
PerfectlyNormal commented 9 years ago

Then I suggest you look at the documentation for TinyMCE and/or tinymce-rails, and get a working setup there before you try using this plugin.

I'm sorry, but I don't have time for hand-holding you through the installation and configuration of TinyMCE.

bobbyworx commented 9 years ago

sorry, it does with this configuration:

toolbar:
  - styleselect | bold italic | undo redo
  - image | link
plugins:
  - image
  - link

only when I specify imageupload, it completely disappears.

PerfectlyNormal commented 9 years ago

If you can create a small demo app where this happens and upload somewhere, or send to me (perchr@northblue.org), I'll take a quick look at it.

bobbyworx commented 9 years ago

okay, sounds good.

bobbyworx commented 9 years ago

I've created the demo app, I'll send it to you any minute now, but maybe this error would help you:

ActionController::RoutingError (No route matches [GET] "/assets/tinymce/plugins/imageupload/plugin.js")
PerfectlyNormal commented 9 years ago

imageupload/plugin.js? Should be uploadimage/plugin.js.

Other than that, might be related to the asset pipeline troubles

bobbyworx commented 9 years ago
    config.assets.precompile += %w( tinymce/plugins/uploadimage/plugin.js tinymce/plugins/uploadimage/langs/ro.js )

ok so I have this in my app.rb file but I get the same error. How can I specify the precompilation under public directory(as you mention in the docs)?

PerfectlyNormal commented 9 years ago

The point of using public is to avoid involving the asset pipeline at all, which means no precompilation. The asset pipeline won't touch anything there, and since TinyMCE doesn't understand/use the pipeline, involving it doesn't make any difference anyways.

A possible issue if you're using Rails 4 is that it doesn't generate non-digested versions of the assets, so you only get tinymce/plugins/uploadimage/plugin-<digest>.js, which TinyMCE won't find.

You could try by adding the gem non-stupid-digest-assets and see if that helps.

bobbyworx commented 9 years ago

ok it shows now! thanks!

Got a bad response from the server

Is the error I got when uploading a picture but I guess there are issues related to this error already

bobbyworx commented 9 years ago

fixed it. thanks for being so responsive!

PerfectlyNormal commented 9 years ago

Glad to hear you got it working.