fix(richtext): blank lines survive into PDFs and read-only previews
Quill 2's semantic HTML saves a blank line as a truly empty <p></p> (no <br> placeholder) — verified in the DB (invoice_sections hold <p></p>, zero <p><br>) — which collapses to nothing outside the editor. cleanQuillHtml (PDF path) and the new restoreQuillBlankLines (order/ invoice read-only previews) restore the placeholder at render time, so existing stored content is covered retroactively. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,17 @@ describe("cleanQuillHtml — inline-style whitelist", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("restores Quill 2's empty <p></p> blank lines to <p><br></p>", () => {
|
||||
// Quill 2's semantic HTML drops the <br> placeholder from blank lines.
|
||||
expect(cleanQuillHtml("<p>A</p><p></p><p>B</p>")).toBe(
|
||||
"<p>A</p><p><br></p><p>B</p>",
|
||||
);
|
||||
// Attribute-carrying and whitespace-only empties too.
|
||||
expect(cleanQuillHtml('<p class="ql-align-center"> </p>')).toBe(
|
||||
'<p class="ql-align-center"><br></p>',
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps stripping scripts, event handlers and js: URLs", () => {
|
||||
const out = cleanQuillHtml(
|
||||
'<p onclick="alert(1)"><script>alert(1)</script>' +
|
||||
|
||||
Reference in New Issue
Block a user