Closed sintro closed 6 years ago
This way a lot of code from here https://github.com/spohlenz/tinymce-rails/issues/213 will be DRYed out.
I've reworked the JavaScript initialization code in the latest version which should provide some more flexibility. In particular, these changes allow multiple configurations to be easily used within the one page.
The main changes are in:
In order to disable the default TinyMCE initialization, you can manually add all of the configurations with:
<%= javascript_tag tinymce_configurations_javascript %>
and then initialize with:
TinyMCERails.initialize('default', { selector: "#myeditor", custom: "options" });
Nice!
Still sad https://github.com/spohlenz/tinymce-rails/blob/master/lib/tinymce/rails/helper.rb#L38 this method (tinymce_configurations_javascript) does not allow to input options for overriding (like tinymce_configuration
).
So one need to bother with options passing from data attributes to javascript initializer (TinyMCERails.initialize
) for options which depends on the particular rendered page.
I've added an options
parameter to the tinymce_configurations_javascript
helper in the 4.7.3 release.
There are option for manual initializing of tinymce, which is usefull almost always if you use turbolinks. But this option - is to fully reimplement all the tinymce initialize script, which is beautiful feature of this gem (to define tinymce configs in one place at tinymce.yml). But what about some option to view's
tinymce
method to disable automatictinyMCEInit()
call? So the method will definetinyMCEInit()
method in body with all global configs, and the programmer will be able to call it from where he wants by calling of this method (probably it should be defined forwindow
scope).