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

List elements deleted if lines of HTML have leading whitespace #6

Closed
aberwristwatch opened this issue Dec 10, 2019 · 1 comment
Closed

Comments

@aberwristwatch
Copy link

aberwristwatch commented Dec 10, 2019

The formatHTML function in quill.htmlEditButton.js is doing a good job of beautifying the raw HTML.
However for me when there is a list in the editor contents the leading whitespace before the <li> tag is causing the editor to lose the list when the OK button is clicked.

A solution that works for me is to remove newlines and trim each of the lines before joining them back together.
So I changed this
const noNewlines = textArea.value.replace(/\r?\n/g, ''); quill.container.querySelector(".ql-editor").innerHTML = noNewlines;

with this

const output = textArea.value.split(/\r?\n/g).map(el => el.trim()); quill.container.querySelector(".ql-editor").innerHTML = output.join('');

@benwinding
Copy link
Owner

Thanks for reporting the issue @aberwristwatch,

Appreciate your solution too. It's fixed in version:1.0.6

Cheers,
Ben

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

2 participants