How to insert plain text in TinyMCE without additional translation lines?

I have a problem with TinyMCE when I use paste_as_text: truein conjunction with forced_root_block: false. Inserting already plain text in the works is fine, but pasting from Word adds extra tags <br>between each new line. It's not like I can just parse them, because it breaks the correct double newline characters from plain text.

I noticed that inserting with ctrl-shift-v fixes this problem, and I would like to do it by the default insert method, but I cannot find a way.

I am currently trying to write a parser for use in paste_preprocess, but since this can be done in other ways, I believe that there should be a better solution.

+4
source share
1 answer

Paste in Microsoft Word is broken, you need to copy and paste the / Cliboard API. You will need to modify Newline.js or Clipboard.js manually.

For example, replace line 63 in Newline.js :

return p.split(/\n/).join('<br />');

with:

return p.replace(/\r?\n/g, '<br>');

If you can open the problem on the plugin page , I will create the correct pull request.

+1
source

Source: https://habr.com/ru/post/1681800/


All Articles