Merge branch 'MDL-76734-master' of https://github.com/andrewnicols/moodle

This commit is contained in:
Sara Arjona 2022-12-28 10:04:25 +01:00
commit 0adda8c66b
3 changed files with 13 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import jQuery from 'jquery';
import Pending from 'core/pending';
import {getDefaultConfiguration} from './defaults';
import {getTinyMCE, baseUrl} from './loader';
@ -382,6 +383,16 @@ export const setupForTarget = async(target, options = {}) => {
instanceMap.delete(target.targetElm);
});
// If the editor is part of a form, also listen to the jQuery submit event.
// The jQuery submit event will not trigger the native submit event, and therefore the content will not be saved.
// We cannot rely on listening to the bubbled submit event on the document because other events on child nodes may
// consume the data before it is saved.
if (target.form) {
jQuery(target.form).on('submit', () => {
editor.save();
});
}
pendingPromise.resolve();
return editor;
};