mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'MDL-80391-main' of https://github.com/stevandoMoodle/moodle
This commit is contained in:
commit
93731ed096
2
lib/editor/tiny/amd/build/editor.min.js
vendored
2
lib/editor/tiny/amd/build/editor.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -415,6 +415,16 @@ const getEditorConfiguration = (target, tinyMCE, options, pluginValues) => {
|
||||
return instanceConfig;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the target for TinyMCE is in a modal or not.
|
||||
*
|
||||
* @param {HTMLElement} target Target to check
|
||||
* @returns {boolean} True if the target is in a modal form.
|
||||
*/
|
||||
const isModalMode = (target) => {
|
||||
return !!target.closest('[data-region="modal"]');
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up TinyMCE for the HTML Element.
|
||||
*
|
||||
@ -496,6 +506,26 @@ export const setupForTarget = async(target, options = {}) => {
|
||||
editor.save();
|
||||
});
|
||||
|
||||
// If the editor is in a modal, we need to hide the modal when window editor's window is opened.
|
||||
editor.on('OpenWindow', () => {
|
||||
if (isModalMode(target)) {
|
||||
const modal = document.querySelector('[data-region="modal"]');
|
||||
if (!modal.classList.contains('hide')) {
|
||||
modal.classList.add('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// If the editor's window is closed, we need to show the hidden modal back.
|
||||
editor.on('CloseWindow', () => {
|
||||
if (isModalMode(target)) {
|
||||
const modal = document.querySelector('[data-region="modal"]');
|
||||
if (modal.classList.contains('hide')) {
|
||||
modal.classList.remove('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pendingPromise.resolve();
|
||||
return editor;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user