TinyMCE显示焦点菜单

时间:2014-07-16 06:22:19

标签: jquery jquery-ui tinymce tinymce-4 tinymce-3

我的项目中我很小。

我有两个文字区域。我只需要显示活动控件。 我有两个选择:

  1. 对两者都有一个共同的控制。
  2. 隐藏非活动编辑器的控件。
  3. 我无法找出第一个选项。 我采用了第二种方法。

    现在,当编辑器处于焦点时,我能够触发事件。 当焦点失焦时,我需要帮助从编辑器中删除菜单和工具。

    以下是关于我如何接近第二个选项的代码:

    setup : function(ed) {
                ed.on("focusout", function() {
                    tinyMCE.activeEditor.execCommand('mceSetAttribute','toolbar','false');
               console.log(tinyMCE.activeEditor.execCommand('mceSetAttribute','toolbar','false'));
                });
                ed.on("focus", function() {
    
                    });
            }
    

1 个答案:

答案 0 :(得分:0)

这适用于tinyMCE 4(假设您使用的是jQuery):

setup: function(editor) {
    editor.on("init", function() {
        editor.contentParent = $(this.contentAreaContainer.parentElement);
        editor.contentParent.find("div.mce-toolbar-grp").hide();
    });
    editor.on('focus', function () {
        editor.contentParent.find("div.mce-toolbar-grp").show();
    });
    editor.on('blur', function () {
        editor.contentParent.find("div.mce-toolbar-grp").hide();
    });
}

次要注意事项:如果使用AngularJS,您也可以使用angular.element(...)代替$(...)