7

I am using the following:

    <textarea
    data-ui-tinymce="tinymceOptions"
    data-ng-disabled="modal.action=='delete'"
    data-ng-model="modal.formData.text"
    id="inputText"
    rows="20"
    required></textarea>

When the tinymce appears the height is just a few centimeters. How can I change the height of the default when it first appears?

Here is a list of the options I am using:

selector: "textarea",           
plugins: [
                        "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
                        "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                        "table contextmenu template textcolor paste fullpage textcolor"
                ],

                toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect fontselect fontsizeselect",
                toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | code | inserttime preview | forecolor backcolor",
                toolbar3: "table | hr removeformat | subscript superscript | charmap | print fullscreen | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft",

                menubar: false,
                toolbar_items_size: 'small',

                templates: [
                        {title: 'Test template 1', content: 'Test 1'},
                        {title: 'Test template 2', content: 'Test 2'}

]

4

6 回答 6

23

来自 javascript

tinymce.init({
   selector: 'textarea',
   height: 200
});

或来自 html

<textarea style="height: 200px;">
于 2016-11-21T10:46:48.733 回答
6

您应该在 CSS 中设置容器对象的高度:

#inputText {
    height : 10000000px;
}
于 2013-07-23T13:27:53.860 回答
1

对于 4.X之前的 tinyMCE 版本,则此代码有效

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

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

对于 tinyMCE 4.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';
      });
   }
});
于 2017-11-24T09:50:49.990 回答
1

对于 TinyMCE 的全局高度设置,编辑 Django 项目的 settings.py:

TINYMCE_DEFAULT_CONFIG = {'height': 120}

对于每个小部件设置,请mce_attrs在表单类中使用:

input = forms.CharField(widget=TinyMCE(mce_attrs={'height': 120}))

使用 django-tinymce 2.7.0 测试。

在后台:&quot;height&quot;: 120,您可以在为 textarea 生成的 HTML 的 data-mce-conf 属性中看到类似字符串。否则,就会出现问题。

于 2018-03-27T08:29:00.337 回答
0

它对我有用(见setTimeout部分)

$(function () {
    window.init_tinymce = function (id, custom_config) {
        var textarea = $('#' + id);

        // Default TinyMCE configuration
        var basic_config = {
            mode: 'none',
            plugins: "link",
            menu: 'none',
            toolbar: 'bold | formatselect | link'
        };

        tinymce.init($.extend(basic_config, custom_config));
        ...

        setTimeout(function(){ //wait for tinymce to load
            console.log('timeout');
            $(tinymce.editors[0].iframeElement).contents().find('body')
                .css('min-height', $(tinymce.editors[0].contentAreaContainer).height() * .9);
        }, 1000);
    };
});

于 2015-05-31T15:54:51.837 回答
0

将此 css 添加到您的自定义样式表中,否则它将降低所有现有编辑器的高度。

.mce-edit-area iframe {
    max-height: 200px;
}
于 2018-10-04T13:34:17.157 回答