简体   繁体   English

更新TinyMCE编辑器高度

[英]Update TinyMCE editor height

I have a custom plugin for TinyMCE that adds a custom button to the toolbar to upload images using AJAX. 我有一个TinyMCE的自定义插件,该插件向工具栏添加了一个自定义按钮,以使用AJAX上传图像。

This is my code: 这是我的代码:

tinymce.activeEditor.execCommand('mceInsertContent', false, '<img src="'+response.url+'" />');

The problem is that after the image is added to the editor the editor height doesn't update. 问题在于,将图像添加到编辑器后,编辑器的高度不会更新。 I must write anything or use Ctrl + A to update the height of the editor. 我必须编写任何内容或使用Ctrl + A来更新编辑器的高度。

Screenshot: https://i.imgur.com/bihm9FC.png 截图: https//i.imgur.com/bihm9FC.png

My TinyMCE settings: 我的TinyMCE设置:

'height'                => 150,

'autoresize_min_height' => 150,

The autoresize plugin doesn't dynamically resize on content insertion - it only makes sure the editor is taking up all the space it can inside it's parent element. autoresize插件不会在内容插入时动态调整大小-它只能确保编辑器占用其父元素内的所有可用空间。

You'll need to add a line to your button code after your execCommand that invokes an editor resize event. 您需要在execCommand调用编辑器调整大小事件之后,在按钮代码中添加一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM