Skip to content

Instantly share code, notes, and snippets.

@tvdeyen
Created April 10, 2015 15:50
Show Gist options
  • Save tvdeyen/db9842808b4cf03ceaf2 to your computer and use it in GitHub Desktop.
Save tvdeyen/db9842808b4cf03ceaf2 to your computer and use it in GitHub Desktop.
Enable Alchemy CMS build in TinyMCE for Spree text areas.
<!-- app/views/admin/shared/_tinymce_enable.html.erb -->
<script charset="utf-8">
var tinyMCEPreInit = {
base: '<%= asset_path('tinymce') %>',
suffix: '.min'
};
$(function() {
// Default tinymce config from Alchemy,
// overridden by some other buttons and skins
// For instance we can't use the alchemy_link button
var init = {
language: '<%= ::I18n.locale %>',
plugins: '<%= Alchemy::Tinymce.plugins.join(',') %>',
<% Alchemy::Tinymce.init.each do |k, v| %>
<%= k %>: <%== v.to_json %>,
<% end %>
skin: 'lightgray',
toolbar: [
'bold italic underline | strikethrough subscript superscript | numlist bullist indent outdent | removeformat | fullscreen',
'forecolor backcolor | formatselect | pastetext charmap hr | undo redo | link unlink anchor | code'
]
};
// Init products description
if ($('textarea#product_description').length > 0) {
init.selector = "textarea#product_description";
init.autoresize_min_height = 420;
tinymce.init(init);
}
// Uncomment, if you want to init all textareas with .tinymce class
// if ($('textarea.tinymce').length > 0) {
// init.selector = "textarea.tinymce";
// tinymce.init(init);
// }
});
</script>
# app/overrides/tinymce.rb
Deface::Override.new(
virtual_path: 'spree/layouts/admin',
name: 'tinymce_load',
insert_bottom: '[data-hook="admin_inside_head"]',
text: "<%= javascript_include_tag 'tinymce/tinymce.min.js' %>",
original: 'a6efdccc4c501b46707d56d3278674cdbd1b354e'
)
Deface::Override.new(
virtual_path: 'spree/layouts/admin',
name: 'tinymce_enable',
insert_bottom: '[data-hook="admin_footer_scripts"]',
partial: 'admin/shared/tinymce_enable',
original: 'e004c3e716cca1f673d5142bdd7c16dc2dc5b403'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment