1

I am using TinyMCE 4.x version, BBCode as a source in my project. Below is the TinyMCE init code for it,

            tinymce.init({
                mode: "textareas",
                editor_selector: "mceEditor",
                resize: "both",
                forced_root_block: false,
                remove_redundant_brs : false,
                verify_html : false,
                force_br_newlines: true,
                force_p_newlines: false,
                remove_redundant_brs : false,
                remove_linebreaks : false,
                valid_elements: 'br',
                plugins: ["autolink link image anchor bbcode code noneditable"],
                toolbar: "bold italic link | code | bbcode",              
        });

If I add newline or extra line/space at the end of content and trying to get content from javascript(tinyMCE.activeEditor.getElement().val()), the content got is in trimmed form. Is there anyway to stop trimming the right trim of the content while we get content from TinyMCE?

I have tried different options from this: Linebreaks in TinyMCE editor show extra line on preview, not in code, tinymce remove text spaces and line breaks link but options does not worked for me.

Does anyone has an idea what changes that I need to make to overcome from this issue?

Community
  • 1
  • 1
Ankit Shah
  • 137
  • 1
  • 13

1 Answers1

0

I had similar issue. solved it with hakish solution ( no tinyMCE documentation for it anywhere) adding below settings inside tinymce.init({... solve the issues for me

indent_before: 'h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
                    'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
                indent_after: 'h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,' +
                    'tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist',
                whitespace_elements: 'p pre script noscript style textarea video audio iframe object code',

indent_before, indent_after - I removed the p element from that list and left all the default I have found in tinymce.js source file. this stopped putting space before and after each p. whitespace_elements - I added the p element to that list and left all the default I have found in tinymce.js source file. this stopped removing trainling spaces in the begining of P element