问题描述
我有一个设置在TextArea上的TinyMCE,并且我希望这个编辑器区域能够随时满足其父div的所有空间。
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.
我有一个获取当前空间并将textarea.style.height设置为它的JS函数,但当启用TinyMCE时,它似乎停止工作。
I have a JS function that get the current space and set the textarea.style.height to it, but when I enables TinyMCE it seems to stop working.
此外,textarea还具有宽度:100%;它在使用TinyMCE时也不会通过HTML渲染来调整大小。
Also, the textarea has width: 100%; it doesn't resize by HTML rendering when it's using TinyMCE too.
有什么想法?
Any ideas?
推荐答案
现在,您应该使用tinyMCE附带的。您必须像这样调用tinyMCE(jQuery版本):
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,
});
我做了这个经验,手动调用 init_instance_callback
在init中提供正确的高度。
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'); }
这篇关于如何自动调整tinyMCE的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!