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

Denotation char span in blot is being flattened by setting innerText #357

Open
crabmusket opened this issue Nov 23, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@crabmusket
Copy link

crabmusket commented Nov 23, 2023

Currently, the MentionBlot adds the value using innerText:

node.innerText += data.value;

Previously, this was innerHTML:

node.innerHTML += data.value;

I assume this change was made for safety reasons. However, this means the resulting HTML has changed from

<span class="mention" data-denotation-char="@" data-value="Mentioned Name" data-id="...">
  <span>
    <span class="ql-mention-denotation-char">@</span>
    Mentioned Name
  </span>
</span>

To

<span class="mention" data-denotation-char="@" data-value="Mentioned Name" data-id="...">
  <span>@Mentioned Name</span>
</span>

This isn't the end of the world, but I think it'd be nice to maintain existing behaviour. I suspect the solution is something like:

    if (typeof this.render === "function") {
      node.appendChild(this.render(data));
    } else {
      node.appendChild(document.createTextNode(data.value));
    }

I'm happy to PR this if you agree! Otherwise it might be worth noting this in the readme for others upgrading from 3.x

@csculley csculley added the bug Something isn't working label Mar 12, 2024
@csculley
Copy link
Collaborator

I'd be in favor of putting back the previous HTML structure with a minor version, but it might not be necessary due to the major version being upgraded.

@rupeshdeotale97
Copy link

@crabmusket / @csculley Any update so far over above issue I'm also facing this issue. We are dynamically replacing placeholder with class="ql-mention-denotation-char" name but now it's not coming in latest version.

@csculley
Copy link
Collaborator

@rupeshdeotale97 Can you make a new Q&A question for that issue with more information here? You should have full access to how list items and mention blot nodes are displayed. The docs webpage also has an example of overriding the mention item however you'd like which might be helpful here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants