5

我遇到了 tinyMCE(所见即所得编辑器)的问题。我实际上是在 HTML 元素(如 DIV)中添加 textarea,该元素当前具有样式属性“display:none”。

当我将 DIV 显示样式更改为可见时,tinyMCE 编辑器显示为禁用。

重要提示:导致问题的设置是“auto_resize”选项。这是我打开/关闭使 tinyMCE 编辑器进入编辑或只读模式的唯一选项。

这是我的代码:

tinyMCE.init({
    mode: "specific_textareas",
                editor_selector: /(RichTextArea)/, 
                theme: "advanced",
                auto_reset_designmode: true,
                auto_resize:true,
                theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull",
                theme_advanced_buttons2: "",
                theme_advanced_buttons3: "",
                theme_advanced_buttons4: "",
                theme_advanced_more_colors: 0,
                theme_advanced_toolbar_location: "external",
                theme_advanced_toolbar_align: "left"
});

...

<a href="#" onclick='document.getElementById("myHiddenDiv").style.display = "block"; return false;'>Show WYSIWYG</a><br/>
<div id="myHiddenDiv" style="display:none">
    <!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->
    <textarea class="RichTextArea" id="elm1" name="elm1" rows="15" cols="80" style="width: 80%">
        &lt;p&gt;This is the first paragraph.&lt;/p&gt;
        &lt;p&gt;This is the second paragraph.&lt;/p&gt;
        &lt;p&gt;This is the third paragraph.&lt;/p&gt;
    </textarea>
</div>

我想知道是否有人知道如何解决该问题?

4

2 回答 2

7

取消隐藏包含的 div 后尝试调用 tinyMCE.init(...)。

于 2009-05-05T17:56:47.557 回答
1

这个问题很老了,但我也有这个问题。我修复了内联样式。

<textarea class="tinymce" style="width: 300px; height: 400px"></textarea>

为了更容易,我在 init() 之前构建了这个简单的脚本来为我做 ir

$('textarea.tinymce').each(function(){
    $(this).css({
        width: $(this).width(),
        height: $(this).height()
    });
})
于 2013-04-25T20:15:54.160 回答