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

[Bug]: Character Count extension does not count characters correctly when there is mention #5777

Open
1 task done
ederssouza-hotmart opened this issue Oct 28, 2024 · 1 comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@ederssouza-hotmart
Copy link

Affected Packages

extension-character-count and extension-mention and suggestion

Version(s)

2.9.1

Bug Description

When using the editor with the extensions @tiptap/extension-mention, @tiptap/suggestion and @tiptap/extension-character-count the character count does not consider the length of the mention, only the @. The error can be reproduced in the mention extension doc itself https://tiptap.dev/docs/examples/advanced/mentions.

image

Browser Used

Chrome

Code Example URL

https://tiptap.dev/docs/examples/advanced/mentions

Expected Behavior

The character count should be 56 not 44.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@ederssouza-hotmart ederssouza-hotmart added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Oct 28, 2024
@nperez0111
Copy link
Contributor

A mention is an inline node, so it only has a width of one.

The real bug here is that the way that prosemirror does text and the way that tiptap does text is different.

When using .textBetween like the chracter extension does: https://github.com/ueberdosis/tiptap/blob/develop/packages/extension-character-count/dist/index.js#L27
it is unaware that the node can be serialized to text because we do not pass the leafText to the nodespec in prosemirror here:

extensionAttributes.map(extensionAttribute => {
return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]
}),
),
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants