TinyMce - 使用autoresize插件时如何将编辑器高度设置为50px以下

时间:2015-09-09 08:30:09

标签: javascript tinymce-4

如何将tinymce编辑器高度设置为36px,当我设置此iframe高度变为67px时。如果我将高度设置在100以上就可以了。我需要编辑器通过键入或粘贴来自动调整大小 我的代码是这样的:

tinymce.init({
    selector: "textarea,
    plugins: ["paste autoresize"],
    height : '40px',
    icon: false, menubar: false, statusbar: false, toolbar: false, autoresize_bottom_margin: 10, object_resizing: false,
    paste_as_text: true, force_br_newlines: true,autoresize_max_height : "300px", 
});

2 个答案:

答案 0 :(得分:2)

我通过设置像

这样的init选项来实现它

tinymce.init({ selector: "textarea, plugins: ["paste autoresize"], autoresize_bottom_margin: 2, autoresize_min_height: 36, autoresize_max_height: 300, icon: false, menubar: false, statusbar: false, toolbar: false, autoresize_bottom_margin: 10, object_resizing: false, paste_as_text: true, force_br_newlines: true, });

答案 1 :(得分:1)

您可以使用min_height配置设置 在您的情况下,代码应为:

tinymce.init({
    selector: "textarea",
    plugins: ["paste autoresize"],
    min_height: 10,
    height : 30,
    icon: false,
    menubar: false,
    statusbar: false,
    toolbar: false,
    autoresize_bottom_margin: 10,
    object_resizing: false,
    paste_as_text: true,
    force_br_newlines: true,
    autoresize_max_height : "300px"
});

如你所说,使用autoresize插件无效。也许这是autoresize插件的问题。无论如何,我测试了另一个选项autoresize_min_height : 30,但似乎这也不起作用。