开发者

tinyMCE - Can you configure an editor height below 100px?

I am not all that familiar with TinyMCE, but I cannot seem to configure it with a height below 100px. I've tried and it seems to always set it as 100px any time it goes b开发者_运维问答elow. I only need a few of the buttons and the editor window will likely never go beyond one line, so I am trying to reduce a bit of interface clutter.


In Version 4.X.X of tinymce there where a lot of changes made. Working code:

tinyMCE.init({
...,
setup: function (ed) {
    ed.on('init', function(args) {
        var id = ed.id;
        var height = 25;

        document.getElementById(id + '_ifr').style.height = height + 'px';
        document.getElementById(id + '_tbl').style.height = (height + 30) + 'px';
    });
},
...,
});


After digging around a bit, it seems that you cannot configure the editor directly with a height below 100px. There is a workaround using the editor init callback to manually set the height. See http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10015 for details.

tinyMCE.init({
    ...,
    setup: function(editor) {
        editor.onInit.add(function() {
            var width = editor.getWin().clientWidth;
            var height = 50;

            editor.theme.resizeTo(width, height);
        });
    }
});


In 3.5.4 theme.resizeTo doesn't seem to be working. This did the trick for me.

tinyMCE.init({
    ...,
    ed.onInit.add(function() {
        var id = ed.id;
        var height = 50;

        document.getElementById(id + '_ifr').style.height = height + 'px';

        //One line with buttons takes roughly 30px, so we add that
        document.getElementById(id + '_tbl').style.height = (height + 30) + 'px'; 
    });
});


With TinyMCE 3.5.2 you can use min_height configuration setting.


Googled "TinyMCE 100px", 1st result: http://tinymce.moxiecode.com/punbb//viewtopic.php?pid=80158

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜