Skip to content

Commit 4efec4c

Browse files
committed
Merge branch 'master' into framework-ui
2 parents 66aae54 + c6e1171 commit 4efec4c

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.rdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Support action link groups to open with click, like actions showing dynamic action link group.
2020
- Open dynamic action link group nested in the menu tree, under the action opening it.
2121
- Add sort_joins to column, defaults to includes value, so it's possible to set sort by SQL without joining the includes, or join with some associations, and preload others.
22+
- Fix when textarea is required and uses tinymce, show the validation error if it's empty and sync the content before submitting.
2223

2324
= 4.1.5
2425
- Fix update_columns global config for field search ac

app/assets/javascripts/jquery/tiny_mce_bridge.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,27 @@
2020
var id = jQuery(this).attr('id');
2121
if (tinymce && tinymce.majorVersion >= 6) {
2222
settings.selector = '#' + id;
23-
if (settings.setup) settings.setup = eval(settings.setup);
23+
var userSetup = settings.setup ? eval(settings.setup) : function () {};
24+
settings.setup = function(editor) {
25+
userSetup(editor); // run what the user already had
26+
27+
/* keep textarea in sync */
28+
var sync = function() { editor.save(); }; // same as triggerSave()
29+
editor.on('change input NodeChange Undo Redo', sync);
30+
};
2431
tinymce.init(settings);
2532
} else { // tinyMCE.majorVersion < 6
33+
settings.init_instance_callback = function(editor) {
34+
var sync = function () { editor.save(); }; // same as triggerSave()
35+
editor.on('change input NodeChange Undo Redo', sync);
36+
if (userInit) userInit(editor); // run user’s callback too
37+
};
2638
tinyMCE.settings = settings;
2739
tinyMCE.execCommand('mceAddEditor', false, id);
2840
}
2941
}
30-
42+
/*const sync = () => editor.save(); // same as triggerSave for this editor
43+
editor.on('change input NodeChange Undo Redo', sync);*/
3144
jQuery(document).on('submit', 'form.as_form', function() {
3245
tinymce.triggerSave();
3346
jQuery('textarea.mceEditor', this).each(function() { tinymce.remove('#'+jQuery(this).attr('id')); });
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.active-scaffold textarea.mceEditor {
2+
opacity: 0;
3+
pointer-events: none;
4+
display: inline !important;
5+
height: 0;
6+
margin: 0;
7+
padding: 0;
8+
width: 0 !important;
9+
float: left;
10+
margin-left: -5px;
11+
}

lib/active_scaffold/bridges/tiny_mce.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ def self.install?
1313
def self.javascripts
1414
['tinymce', 'jquery/tiny_mce_bridge']
1515
end
16+
17+
def self.stylesheets
18+
['tiny_mce_bridge']
19+
end
1620
end

0 commit comments

Comments
 (0)