简体   繁体   中英

Load a TinyMCE editor inside a TinyMCE modal in wordpress

I'm using TinyMCE to open a modal. And inside that modal i would want to add an instance of tinyMCE. I'm opening the modal passing some objects . I followed this guide

            editor.windowManager.open(
                //  Properties of the window.
                {
                    title: "TDSK's Dumb Shortcode Creator",   //    The title of the dialog window.
                    file:  url + '/tinymce-dialog.html',      //    The HTML file with the dialog contents.
                    width: 1000,                               //    The width of the dialog
                    height: 600,                              //    The height of the dialog
                    inline: 1                                 //    Whether to use modal dialog instead of separate browser window.
                },

                //  Parameters and arguments we want available to the window.
                {
                    editor: editor,   //    This is a reference to the current editor. We'll need this to insert the shortcode we create.

                    jquery: $,        //    If you want jQuery in the dialog, you must pass it here.
                    tinymce: tinymce
                }
            );

In the tinymce-dialog.html

var passed_arguments = top.tinymce.activeEditor.windowManager.getParams();
var $ = passed_arguments.jquery;

var jq_context = document.getElementsByTagName("body")[0];
$( function() {
    passed_arguments.tinymce.execCommand( 'mceAddEditor', false, $( '#sectionContent_1', jq_context )[0] );
} );

This actually creates an instance of TinyMce which is not working though

在此处输入图片说明

probably the reason is an error

TypeError: elm is undefined

which points to

    aria: function(name, value) {
        var self = this, elm = self.getEl(self.ariaTarget);

        if (typeof value === "undefined") {
            return self._aria[name];
        }

        self._aria[name] = value;

        if (self.state.get('rendered')) {
            elm.setAttribute(name == 'role' ? name : 'aria-' + name, value);
        }

        return self;
    },

what could be causing this?

最后,我不得不停止使用TinyMce模态,而使用引导程序模态。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM