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

Break tags are stripped from Break blot in getSemanticHTML #4159

Open
amyasmith opened this issue May 1, 2024 · 2 comments
Open

Break tags are stripped from Break blot in getSemanticHTML #4159

amyasmith opened this issue May 1, 2024 · 2 comments

Comments

@amyasmith
Copy link

The Break blot for empty newlines is rendered as <p><br></p> in the editor, which correctly shows multiple sequential newlines, but this becomes <p></p> when converted to HTML with getSemanticHTML(). This causes a discrepancy in the output.

Steps for Reproduction

  1. Visit the Quill playground
  2. Enter some newlines
  3. Check inspector
  4. Run getSemanticHTML()

Expected behavior:
Semantic HTML will include <br> tags

Actual behavior:
Semantic HTML does not include <br> tags

Platforms:

Tested on MacOS Sonoma on Firefox and Chrome

Version:

2.0.1

@amyasmith
Copy link
Author

I would appreciate if anyone has a quick fix to this that can be implemented with Parchment/Registry. I don't want to have to do replaceAll() on the HTML output to fix this.

@AltiorPetitM
Copy link

AltiorPetitM commented May 3, 2024

Hey ^^, One way i found was to make the p become a div, and then replace the empty <div></div> with <div><br></biv> when i export the html using the getSemanticHTML()

import Quill from 'quill'

const Block = Quill.import('blots/block')
Block.tagName = 'DIV'

export default Block

You can use this to make the p tag become a div and then when you want to export you can do this quill.getSemanticHTML().replace(/<div><\/div>/g, '<div><br></div>')

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