-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
unneeded line break.... <p><br></p> #1328
Comments
That is needed because otherwise you could not put your cursor into the empty line, the browser would ignore it. |
I fixed it in the editor CSS. By changing the
maybe an adjustment that can be made to the Quill theme css |
Thats all I have to say. |
Hi, is it posible (and how can be done) to remove |
|
Is there a way to make it so that each paragraph is separate? People shouldn't be separating paragraphs with an empty paragraph/br element in between. Should I just give a margin-bottom to all paragraphs? |
I think that the correct behaviour should be to not create adjacent What am I missing? |
Finally found solution to this and many related issues. #1379 (comment) |
That would only replace the first instance of |
Does anyone have an actual solution to this or is the current solution still "don't use Quill"? |
You saved my life with this codepen. |
I was facing the same problem and designed a hack for myself. Someone might find it useful `var justHtml = quill_editor.root.innerHTML;
With this code, i was able to safely remove only trailing empty paragraphs. The reason i am using :last-child is because, sometimes, users space out the script themselves using the enter key. to keep those spacing, only the last paragraph should be targeted. Also, one may wonder if this does not affect the html in the quill editor, well no. This code runs on input event. Therefore, the check is done whenever a user enters something. If the user for instance presses the enter key without typing anything, the innerhtml saved in the exportation input will be without the last paragraph entered by the user. In case the user continues typing, the paragraph will therefore fail to be removed using the (p:last-child).remove() |
to remove all trailing empty paragraphs whether at the end or the beginning, replace the "if" statement with a "while" statement. To remove trailing beginning while space, add a while statement that makes use of :first-child |
|
To remove duplicates but leave one instance. const noNewLines = html.replace(/(<p><br><\/p>)+/g, "$1") |
Hey @cozzbie it was nice idea and trust me in between serious conversation reading this kind of reply lighten my mood. Anyway let me put this question in my way - So I replaced my Now the problem is that before and end of text unwanted break tag getting added link this:
In case there are 2 paragraph and user added break in between para then it will looks like -
I want to remove only starting and ending of Any help with this would be greatly appreciated. Thank you in advance. |
I came up with this regex here, I hope it helps someone: const processedHtml = html.replace(/(^([ ]*<p><br><\/p>)*)|((<p><br><\/p>)*[ ]*$)/gi, "").trim(" "); It replaces all beginning and ending instances of |
As @gaborsar replied
I solved my problem with CSS as follows:
In HTML, where the text result will be displayed, you can also do it in the ql-editor style. |
Is this normal?
It seems grabbing the innerHTML results in unneeded
<p><br></p>
spacing wherever there is blank line. I can filter it out for now, but is it an issue to address in Quill?tnx
The text was updated successfully, but these errors were encountered: