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

[2.0.3] getSemanticHTML is broken #4509

Open
boris-petrov opened this issue Dec 1, 2024 · 4 comments
Open

[2.0.3] getSemanticHTML is broken #4509

boris-petrov opened this issue Dec 1, 2024 · 4 comments

Comments

@boris-petrov
Copy link

Steps for Reproduction

  1. Reproduction
  2. Check the console

Expected behavior:
The text in the editor is a text with multiple spaces. getSemanticHTML returns <p>a&nbsp;text&nbsp;with&nbsp;multiple&nbsp;spaces</p>. Which is wrong - the semantics of the text has changed.

Actual behavior:
See above.

Platforms:
Any.

Version:
2.0.3

@islandmyst
Copy link

Introduced wtih Commit 07b68c9.

The end result of replacing all spaces with &nbsp; (Non Breaking Space) is that the words no-long wrap at word boundaries, and instead overflow.

Example

An alternative implementation of editor.js converHTML() that preserves whitespace might replace all but one consecutive space character with   be:

  if (blot instanceof TextBlot) {
    const escapedText = escapeText(blot.value().slice(index, index + length));
    return escapedText.replaceAll(/  +/g, (match) => "&nbsp;".repeat(match.length - 1) + " ")
  }

A work around (which replaces the last consecutive &nbsp; with a space) until a fix is implemented is:

quill.getSemanticHTML().replaceAll(/((?:&nbsp;)*)&nbsp;/g, '$1 ')

@frederikhors
Copy link

I think this is bad. Sometimes I need to write &nbsp; literally in the editor.

Can we revert to the amazing getSemanticHTML() method of the 2.0.2 please?

@Sergiobop
Copy link

I think @luin can help us here

Thanks

@rubiesonthesky
Copy link

This is quite critical bug to our project. This changes how the values are saved to database. Luckily this didn't hit production before noticing.

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

5 participants