【问题标题】:Load a TinyMCE editor inside a TinyMCE modal in wordpress在 wordpress 的 TinyMCE 模式中加载 TinyMCE 编辑器
【发布时间】:2015-11-13 00:54:54
【问题描述】:

我正在使用 TinyMCE 打开一个模式。在那个模式中,我想添加一个 tinyMCE 的实例。我正在打开模式passing some objects。我关注了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
                }
            );

在 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] );
} );

这实际上创建了一个不起作用的 TinyMce 实例

可能原因是错误

TypeError: elm 未定义

指向

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

这可能是什么原因造成的?

【问题讨论】:

  • 也许如果您使用非缩小版本的 tinymce 运行,可能会更清楚错误是什么!
  • @dev-nullyeah 试图这样做
  • @dev-null 完成,抱歉我之前没有这样做
  • 如果您查看调用堆栈,它在说什么?那么行号等呢...尝试在该行添加一个条件断点(!elm)。这将在错误发生之前停止您的代码。现在您可以回顾调用堆栈。
  • @dev-null 我复制了这个函数。我想知道我在对话框中使用的 tinymce 编辑器实例是否有 jQuery 引用父窗口

标签: javascript jquery wordpress tinymce tinymce-4


【解决方案1】:

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

【讨论】:

  • 你能分享一下你是如何使用引导模型做到这一点的吗?我还想在引导模式面板内的文本框中附加一个 tinymce 编辑器
猜你喜欢
  • 1970-01-01
  • 2014-07-19
  • 1970-01-01
  • 2013-11-11
  • 1970-01-01
  • 2022-07-15
  • 2012-10-27
  • 1970-01-01
  • 2021-09-10
相关资源
最近更新 更多