spohlenz / tinymce-rails

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

Error: "global not defined" #234

Closed d-schloss-mvg closed 6 years ago

d-schloss-mvg commented 6 years ago

When using the gem I am getting an error "global not defined" in Browser.

Probably related to: https://github.com/tinymce/tinymce/issues/4171

Affected version: v4.7.5

turgs commented 6 years ago

Me too, I need to downgrade to the previous gem version to resolve this currently. The error in my firefox console is:

referenceError: global is not defined:
jquery.tinymce.self-460f2c94f6638222134d0af740305fb5d636f2b0408dc3fe3fbf542f72fe03bb.js:1:32

Gemfile

gem 'tinymce-rails', "~> 4.7"

/assets/javascripts/application.js

//= require tinymce-jquery
//= require views/myapp

/assets/javascripts/views/myapp.js.erb

/*
 * TINYMCE
 * ===============
 */

$(document).on('page:load ready', function() {

  if (typeof tinyMCE != 'undefined') {
    tinyMCE.remove();
    tinyMCE.init({
      selector: "body.case_notes textarea.tinymce",
      toolbar: ["bold italic bullist link forecolor table | undo redo "],
      plugins: "link,lists,textcolor,colorpicker,autoresize,table",
      menubar: false,
      statusbar: false,
      autoresize_bottom_margin: 50,
      branding: false,
      table_default_styles: "width: 100%",
      content_css: "<%= asset_path 'tinymce_content_styles.css' %>",
      setup: function(editor) {
        // <garlic compatability>: this to ensure garlicjs can save drafts
        editor.on("input change keyup", function(e){
          if ($(editor.getElement()).val() == editor.getContent())
            return;
          editor.save(); // updates this instance's textarea
          $(editor.getElement()).trigger('change'); // for garlic to detect change
        });
        // </garlic compatability>
      },
    });
  } else {
    setTimeout(arguments.callee, 50);
  }

});

My current workaround was to just update the gemfile to prevent the upgrade:

gem 'tinymce-rails', "~> 4.7", '<= 4.7.4'
a-barbieri commented 6 years ago

Same error here.

To me it's fine in development environment, but when I test with rspec-rails (3.7.2) and capybara (2.17.0) on selenium-webdriver (3.8.0) I get the error message.

tinymce-rails (4.7.5) with tinymce-jquery

brian-kephart commented 6 years ago

Same symptoms/fix here. It looks like the error is in TinyMCE v4.7.5, though, not this gem. It looks like it was fixed the day after, but the 4.7.6 release just happened today. This issue should take care of itself once the version is updated.

spohlenz commented 6 years ago

tinymce-rails 4.7.6 has now been released to RubyGems.