Hello! 😃
I'm experiencing an inconsistency in how my tinymce / jce plugin is behaving while using the windowManager.close() functionality.
What I'm expecting: window.parent.postMessage( { mceAction: 'close', },'*',) should close the active dialog window.
This is the basic plugin:
(function () {
tinymce.create('tinymce.plugins.MyPlugin', {
init: function (ed, url) {
window.addEventListener('message', function (event) {
const { data } = event;
if(data.mceAction === 'close') {
// Do something with the data received here
ed.execCommand('mceClose', false); // doesn't do anything
ed.windowManager.close(); //doesn't do anything
document.querySelector('.mceModalClose').click(); // <--- does work in theory
}
if(data.mceAction === 'insertContent') {
ed.execCommand('mceInsertContent', false, data.content);
}
});
ed.addButton('MyPluginBtn', {
title: 'My Plugin',
image: url + '/img/myplugin.png',
onclick: function () {
ed.windowManager.open({
title: 'MyPlugin',
url: 'http://hosted iframe page.html',
inline: true,
width: 750,
height: 400,
});
}
});
}
});
tinymce.PluginManager.add('myplugin', tinymce.plugins.MyPlugin);
})();
This iframe plugin code inserts content (working) and closes the dialog (works in tinymce but not inside jce):
const insertContent = e => {
if (window.parent) {
window.parent.postMessage(
{
mceAction: 'insertContent',
content: `[${e.currentTarget.getAttribute('alt')}]`,
},
'*',
);
window.parent.postMessage(
{
mceAction: 'close',
},
'*',
);
}
};