【问题标题】:tinyMCE - Can you configure an editor height below 100px?tinyMCE - 您可以配置低于 100 像素的编辑器高度吗?
【发布时间】:2010-10-19 20:29:41
【问题描述】:

我对 TinyMCE 不是很熟悉,但我似乎无法将其配置为高度低于 100 像素。我已经尝试过了,它似乎总是在任何时候将其设置为 100px。我只需要几个按钮,编辑器窗口可能永远不会超过一行,所以我试图减少一些界面混乱。

【问题讨论】:

    标签: javascript tinymce wysiwyg


    【解决方案1】:

    在 tinymce 的 4.X.X 版本中进行了很多更改。 工作代码:

    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';
        });
    },
    ...,
    });
    

    【讨论】:

    • 在删除最后一行 (id + '_tbl') 后为我工作不存在。谢谢!
    【解决方案2】:

    经过一番挖掘,似乎您无法直接将编辑器配置为高度低于 100px。有一种使用编辑器初始化回调手动设置高度的解决方法。详情请见http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10015

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

    【讨论】:

    【解决方案3】:

    在 3.5.4 中 theme.resizeTo 似乎不起作用。这对我有用。

    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'; 
        });
    });
    

    【讨论】:

      【解决方案4】:

      使用 TinyMCE 3.5.2,您可以使用 min_height 配置设置。

      【讨论】:

        【解决方案5】:

        谷歌搜索“TinyMCE 100px”,第一个结果:http://tinymce.moxiecode.com/punbb//viewtopic.php?pid=80158

        【讨论】:

        • 是的,可以,但它需要编辑 TinyMCE 源,我不想这样做。
        猜你喜欢
        • 2018-05-10
        • 1970-01-01
        • 2012-03-24
        • 2019-08-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-20
        相关资源
        最近更新 更多