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

End Of Line char translate to <p> or <br> #54

Closed
jfgirard opened this issue Oct 7, 2013 · 5 comments
Closed

End Of Line char translate to <p> or <br> #54

jfgirard opened this issue Oct 7, 2013 · 5 comments

Comments

@jfgirard
Copy link

jfgirard commented Oct 7, 2013

I've noticed that the behaviour is not the same when I type a bunch of paragraphs and when I paste the same content (using forcePlainText).

Typing:

<p>
paragraph1
</p>
<p>
paragraph2
</p>

Pasting:

<p>
paragraph1
<br>
paragraph2
</p>

I think it would be better to have the same behaviour.

To create <p> instead of <br> while pasting, the change would be:

document.execCommand('insertHTML', false, e.clipboardData.getData('text/plain').replace(/[\r\n]/g, '<br>'));
becomes
document.execCommand('insertHTML', false, '<p>' + e.clipboardData.getData('text/plain').replace(/[\r\n]/g, '</p><p>') + '</p>');

Jeff

@daviferreira
Copy link
Member

Sounds cool, do you want to commit that and open a PR or should I just do it? 👍

@jfgirard
Copy link
Author

jfgirard commented Oct 7, 2013

Cool. Let's play by the rule, I'll submit a PR tomorrow.

@dmitric
Copy link
Contributor

dmitric commented Oct 8, 2013

What I just did -- #55 -- I believe solves this. Although it's a split based way of doing it vs replace.

@jfgirard
Copy link
Author

jfgirard commented Oct 8, 2013

Yeah, #55 is the same fix. Good job, there is no need for a duplicate.

@jfgirard jfgirard closed this as completed Oct 8, 2013
@daviferreira
Copy link
Member

Thanks, guys!

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

3 participants