mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUG Trigger TinyMCE onChange more frequently
Periodically check for inline changes when focused, since TinyMCE's onChange only fires on certain actions like inserting a new paragraph, as opposed to any user input. This also works around an issue where the "save" button wouldn't trigger if the click is the cause of a "blur" event after an (undetected) inline change. This "blur" causes onChange to trigger, which will change the button markup to show "alternative" styles, effectively cancelling the original click event.
This commit is contained in:
parent
d5510f54b3
commit
d2eef63b7d
@ -60,6 +60,24 @@ ss.editorWrappers.tinyMCE = (function() {
|
||||
// Patch TinyMCE events into underlying textarea field.
|
||||
ed.onInit.add(function(ed) {
|
||||
jQuery(ed.getElement()).trigger('editorinit');
|
||||
|
||||
// Periodically check for inline changes when focused,
|
||||
// since TinyMCE's onChange only fires on certain actions
|
||||
// like inserting a new paragraph, as opposed to any user input.
|
||||
// This also works around an issue where the "save" button
|
||||
// wouldn't trigger if the click is the cause of a "blur" event
|
||||
// after an (undetected) inline change. This "blur" causes onChange
|
||||
// to trigger, which will change the button markup to show "alternative" styles,
|
||||
// effectively cancelling the original click event.
|
||||
var interval;
|
||||
jQuery(ed.getBody()).on('focus', function() {
|
||||
interval = setInterval(function() {
|
||||
ed.save();
|
||||
}, 5000);
|
||||
});
|
||||
jQuery(ed.getBody()).on('blur', function() {
|
||||
clearInterval(interval);
|
||||
});
|
||||
});
|
||||
ed.onChange.add(function(ed, l) {
|
||||
// Update underlying textarea on every change, so external handlers
|
||||
|
Loading…
x
Reference in New Issue
Block a user