Skip to content

Replacing default WYSIWYG editor with TinyMCE 4

Tom Hensel edited this page Apr 6, 2014 · 5 revisions

!!! TineMCE-4 is work in progress, please be very careful applying this to a production setup. Better go for TinyMCE-3.

  • Add this to your Gemfile:
gem 'tinymce-rails', :git => '[email protected]:spohlenz/tinymce-rails.git', :branch => 'tinymce-4'
gem 'tinymce-rails-langs', :git => '[email protected]:spohlenz/tinymce-rails-langs.git', :branch => 'tinymce-4'

  • Include assets accordingly in app/assets/javascripts/application.js (we are going to use the jquery version):
//= require tinymce
  • Optionally, if you like to prefer the jQuery version use
//= require tinymce-jquery

instead. Please note this verison might perform worse or better depending on browsers and stuff.

  • Run bundler:
$ bundle install
  • Create coffeescript file at app/assets/javascript/comfortable_mexican_sofa/admin/application.js.coffee:
#= require tinymce

window.CMS.wysiwyg = ->
  tinymce.init
    selector: 'textarea[data-cms-rich-text]'
    # any additional tinymce configuration can go here
  • tinymce-rails-langs will use the current locale. You may set language to override:
    # any additional tinymce configuration can go here
    language: 'de'
    plugins: 'autosave anchor image charmap link paste preview print visualchars'
  • Delete app/assets/javascript/comfortable_mexican_sofa/admin/application.js if it exists. If you have stuff defined in there you need to migrate it to coffeesript as comfy will use that first (and exclusivley then).