How to automatic resize tinyMCE?

后端 未结 12 1481
小蘑菇
小蘑菇 2020-12-01 09:03

I have a TinyMCE that is set over a TextArea, and I want this editor area to ocuppy all the space of its parent div, all times.

I have a JS function that get the cur

12条回答
  •  半阙折子戏
    2020-12-01 09:52

    Nowadays, you should use the autoresize plugin that comes with tinyMCE. You will have to call tinyMCE like this (jQuery version):

    $('.tinymce').tinymce({
      theme : 'advanced',
      plugins : 'autoresize',
      width: '100%',
      height: 400,
      autoresize_min_height: 400,
      autoresize_max_height: 800,
    });
    

    I made the experience, that it may be helpful to manually call the resizing in the init_instance_callback to provide the correct height on init. Add this parameter to the passed options, if you need this:

    init_instance_callback: function (inst) { inst.execCommand('mceAutoResize'); }
    

提交回复
热议问题