tiniMCE不在jsPanel中初始化

时间:2015-12-03 12:34:53

标签: javascript jquery tinymce

我使用jsPanel在我的网站上出现了一些模态窗口。

在jsPanel init上,我使用textarea和回调函数指定内容。

创建jsPanel之后,我尝试在回调中初始化一个tinyMCE。我测试tinyMCE实例,我的编辑器在实例列表中...但是在jsPanel中它显示为普通的textarea,而不是tinyMCE。

有什么想法吗? 这是代码:

function oninitjspanel()
{
    console.log('before init modal mce');
    tinymce.init({
        selector: "#email_message",
        entity_encoding : "raw",
        encoding: "UTF-8",
        theme: "modern",
        height: "100%",
        width: "100%",
        plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
        ],
        toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image preview media | forecolor backcolor emoticons",
        image_advtab: true,
    });
    console.log('after init modal mce');
    for (var i = 0; i < tinymce.editors.length; i++)
    {
        console.log(i + " Editor id:", tinymce.editors[i].id);
    }  
}

$('#new_document').click (function () {
    var content = '<div id="choix_document"><textarea id="email_message"></textarea></div>';                
    $.jsPanel({
        content:        content,
        position:       "center",
        theme:          "success",
        title:          "Nouveau document/email",
        size:           {   width:  function(){ return $(window).width()*0.75 }, 
                            height: function(){ return $(window).height()*0.75 } },
        toolbarFooter:  "<div class='email_submit'>Envoyer email</div><div id='email_returnmessage'></div>",
        callback:       oninitjspanel(),
    });

});

控制台日志:

before init modal mce
after init modal mce
0 Editor id: model_editor
1 Editor id: email_message

编辑:还有一件事,因为tinyMCE在模态中有焦点问题,我在我的页面上应用加载以下内容以防止出现问题:

$(document).on('focusin', function(e) {
    if ($(e.target).closest(".mce-window, .moxman-window").length) {
        e.stopImmediatePropagation();
    }
});

1 个答案:

答案 0 :(得分:1)

只需查看https://github.com/Flyer53/jsPanel/issues/51

即可

但我猜你是那个在GitHub的jsPanel问题页面上问同样问题的人呢?