question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

newline character is auto removed by quill

See original GitHub issue

Steps for Reproduction

  1. I am using quill and while rendering the text in quill, last newline character gets removed automatically.
  2. <p>Sales S2s</p><ul><li>Provide over sight over overall sales activities of the desk</li></ul><p><br></p> . This is the string I am rendering to quill.

Expected behavior:

  • last tag <p><br></p> should not be removed

Actual behavior:

  • last new line br tag is removing while calling setContents function in quill

Platforms: IE, Chrome, Win7

Technologies Angular with Typescript

Version: Quill.1.3.6

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:23
  • Comments:11

github_iconTop GitHub Comments

5reactions
seanjhulsecommented, Mar 11, 2019

This was my silly solution:

if (text && text.substr(text.length - 11) == "<p><br></p>") {
	text = text.substr(0, text.length - 11) + "<p>&#8205;</p>"
}

It works pretty well… Unfortunately, Quill seems to find any </br>, <br>, or <br/ > tag I put inside that. Even <p><span /></p> gets removed. They are pretty good at catching any non-text content in a set of <p></p> at the end of the paragraph.

&#8205; is the “Zero Width Joiner” that is used in Unicode for languages that have no space between certain unicode characters. Languages like Arabic need the ability to join the two characters together with no space. It’s mostly okay for my use-case.

0reactions
nia3ycommented, Oct 24, 2022

This was my silly solution: if onChange‘s source === ’api‘, return.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quill Adding Unwanted Line Breaks to Posted Text <p><br></p>
When pasting or typing text Quill is adding unnecessary line breaks to ... newline character is prepended in the delta object for the...
Read more >
unwanted line break (\n) in Quill pre-1 after first character typed
When creating an editor, then clicking in it and tapping the first character, quill introduces a line break "automatically", ...
Read more >
API - Quill Rich Text Editor
Sets contents of editor with given text, returing a Delta representing the change. Note Quill documents must end with a newline so one...
Read more >
quill-2.0-dev | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Quill: The DOM, Parchment, and Delta views of the document
The most remarkable thing with the Quill editor, ... that relate to blocks are applied only to the newline character(s) in the the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found