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

2020 — Get contenteditable plaintext with correct linebreaks #6

StephenHaney opened this issue Dec 21, 2021 · 3 comments


Copy link

No description provided.

Copy link

Thank you. I'm using it!

Copy link

ntorrey commented Sep 16, 2022

Thank you - me too! If the first childnode is a div an extra new line is added. So I just added an additional condition (i !== 0):

if (childNode.nodeName === 'DIV' && isOnFreshLine === false && i !== 0) {
  // Divs create new lines for themselves if they aren't already on one
  newValue += '\n'

Copy link


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants