This commit is contained in:
Sara Arjona 2024-02-28 17:09:43 +01:00
commit 93731ed096
No known key found for this signature in database
3 changed files with 32 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

@ -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;
};