1
votes

Here my problem: I have some different text area (isn't Wordpress Classic Editor, but many Wysiwyg editor from Visual Composer plugin). My theme include in the tinymce some shortcodes. But when I want to insert shortcode in a specific textarea, the shortcode appears in the classic editor everytime. So I would try to say in the code "put the code in the text box on which I want to insert the shortcode and not in the traditional publisher". Here my code I think the solution could be :

    addWithPopup: function(ed, title, id) {
        ed.add({
            title: title,
            onclick: function() {
                tinyMCE.activeEditor.execCommand('FreshShortcodesPopup', false, {
                    title: title,
                    identifier: id
                });
            }
        });
    },

Hope you can help me... Regards. math.

1

1 Answers

0
votes

Don't use tinyMCE.activeEditor to address the editor. tinyMCE.activeEditor won't change unless the user explicitly clicks into another editor. Another trap is that tinyMCE.activeEditor is not initialized unless the an editor is clicked at all. It is better to address the editor instance using its id:

tinymce.get('your_editor_id').execCommand(...

UPDATE: what about

        onclick: function(ed) {
           console.log('ed:',ed);
           ed.execCommand('FreshShortcodesPopup', false, {
                title: title,
                identifier: id
            });
        }