Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding <br /> in empty divs so new line is preserved when paste the html back MS Word #83

Open
charles-cheng opened this issue May 13, 2021 · 0 comments

Comments

@charles-cheng
Copy link

Our web application receives files in rtf format and use rft.js to convert rtf to html. Then we save the html version to OS clipboard with text/html format (using web clipboard API). So user could then paste the content to other OS native rich text editor (MS Word for example). We found all empty lines are lost during this process. Here is an example:

Converting rtf to html:
rtf:

{\rtf1 \ansi\ansicpg1252
{
\plain \f5 \fs24 \cf0  test line1
\par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \par \pard \ltrpar\li0 \fi0 \ri0 \sl240 \sb0 \sa0 \plain \f5 \fs24 \cf0 test line4
}

rtf.js generated html:

<div><span style="font-size: 12pt"> test line1</span></div>
<div style="text-align: left"></div>
<div style="min-height: 12pt; text-align: left"></div>
<div style="min-height: 12pt; text-align: left"></div>
<div style="min-height: 12pt; text-align: left">
  <span style="font-size: 12pt">test line4</span>
</div>

The HTML looks good in the browser but when copy the html from web browser and paste it to a rich text editor (like MS Word), the three empty lines in between are missing.

Can we just add <br /> tag in empty divs like below, so all empty lines are preserved when pasting back to OS native rich text editor.

<div><span style="font-size: 12pt"> test line1</span></div>
<div style="text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left"><br /></div>
<div style="min-height: 12pt; text-align: left">
  <span style="font-size: 12pt">test line4</span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant