You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Online

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

#104011 JCE plugin is not closing dialog...

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by groovezog on Monday, 27 April 2020 15:11 BST

groovezog
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. https://lauren.tourism-engine.com/images/Screen%20Shot%202020-04-24%20at%204.25.46%20PM.png 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',
      },
      '*',
    );
  }
};

Ryan
Which version of the editor are you using?

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

groovezog
Hey Ryan, I knew I forgot something!
JCE v2.6.38

groovezog
I see now that's not the latest version, let me upgrade that and see what happens, thanks!