If I have content preloaded in textarea then I have new lines converted to "br" tags.
But if I try to set content dynamically (not pasting) to tinymce textarea by using its setContent function new lines are missing.
I use v.3.4.7, tried v.3.5.6 (the latest by far) and it removes new lines even on page loading.
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
editor_selector: "EmailBody",
theme: "advanced",
language: "en",
charLimit: 10,
plugins: "table,advhr,advlink,insertdatetime,preview,print,contextmenu,paste,directionality",
theme_advanced_buttons1_add: "fontselect,fontsizeselect",
theme_advanced_buttons2_add: "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "pastetext,pasteword,separator",
theme_advanced_buttons3_add_before: "tablecontrols,separator",
theme_advanced_buttons3_add: "advhr,separator,ltr,rtl,separator",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
plugi2n_insertdate_dateFormat: "%Y-%m-%d",
plugi2n_insertdate_timeFormat: "%H:%M:%S",
paste_use_dialog: false,
theme_advanced_resizing: false,
theme_advanced_resize_horizontal: true,
paste_auto_cleanup_on_paste: true,
paste_convert_headers_to_strong: false,
paste_remove_spans: true,
width: "100%",
paste_remove_styles: true,
valid_elements: "a[href|target=_blank],strong/b,div[align],p,br,i,u",
content_css: "/css/tinymce_bigger_default_font.css",
forced_root_block: false,
force_br_newlines: true,
force_p_newlines: false,
apply_source_formatting: false,
remove_linebreaks: false,
convert_newlines_to_brs: true
});
</script>
function Click()
{
var text = document.getElementById("preText").innerText;
tinyMCE.activeEditor.setContent(text);
}
<pre id="preText">Text
Text
</pre>
The result must be as follows:
Text
Text
But instead I get:
TextText