Lokesh Waran
Lokesh Waran

Reputation: 113

Change default new line to <p> tag tinymce rails

I am using tinymce and save my content to db. What happened is when i press enter in the tinymce it is inserting <br> tag.

so i changed something in the tinymce config to:

tinyMCE.init({
  force_br_newlines : false,
  force_p_newlines : true,
  ...
}

This severed my purpose. But when i paste the content from word. Its still inserts <br>.

Is there any work around for this.

Thanks in advance.

Note: My tinymce version is 3.4.7

Upvotes: 1

Views: 368

Answers (1)

Thariama
Thariama

Reputation: 50832

Yes, there is. You may modify pasted content as you like using the paste_preprocess - Tinymce config parameter.

tinymce.init({
    paste_preprocess: function(plugin, args) {
        console.log(args.content);

        // your modifications here

        // example
        args.content = args.content.replace(/<br>/, '');
    }
});

Upvotes: 2

Related Questions