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]: Codeblock removes "tagged" users #5609

Closed
1 task done
kart-c opened this issue Sep 10, 2024 · 4 comments
Closed
1 task done

[Bug]: Codeblock removes "tagged" users #5609

kart-c opened this issue Sep 10, 2024 · 4 comments
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

@kart-c
Copy link

kart-c commented Sep 10, 2024

Affected Packages

@tiptap/extension-mention, @tiptap/extension-code-block

Version(s)

2.6.6

Bug Description

Adding a codeblock removes the mentioned user. I have also tried cloning the repository and the same issue can be reproduced in the demos\src\Nodes\Mention\React\index.jsx project (by adding the Codeblock extension.)

Steps to reproduce -

  1. Tag a user
  2. Add codeblock to that particular line. The tagged user is removed
  3. Removing the codeblock removes the mention as well

Browser Used

Chrome

Code Example URL

https://codesandbox.io/p/sandbox/magical-meitner-zwlpq3

Screen.Recording.2024-09-11.100926.mp4

Expected Behavior

Codeblock should not remove the mention text.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@kart-c kart-c 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 Sep 10, 2024
@nperez0111
Copy link
Contributor

A code block only accepts text as its content. A mention is implemented as an inline node so it is removed when converting between the paragraph which allows that kind of content into a code block. So this is expected behavior.

@kart-c
Copy link
Author

kart-c commented Sep 12, 2024

Hey @nperez0111 is there a reason why code only accepts text and not inline* as its content?
If I were to use codeblock on a tagged user in either discord or slack it works as expected which is why I raised it as an issue.

Screen.Recording.2024-09-12.094700.mp4

@nperez0111
Copy link
Contributor

Hey @nperez0111 is there a reason why code only accepts text and not inline* as its content? If I were to use codeblock on a tagged user in either discord or slack it works as expected which is why I raised it as an issue.

There definitely is a reason why it only accepts text, code is edited slightly differently than normal text (e.g. newlines are meaningful), and it does not make sense to be able allow things like formatting on code (e.g. what does it mean to bold a for loop).

There could probably be a more graceful way of trying to preserve the mention text. I wonder if it could just use the renderText method to "downlevel" to text. But atm I'm unsure how that would actually work since this is up to prosemirror in how it chooses to "fit" content.

I hope this answers your question.

@kart-c
Copy link
Author

kart-c commented Sep 16, 2024

Thanks @nperez0111 for the explanation.

It would be nice if the mentioned text was just converted into plain text.

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
Status: Done
Development

No branches or pull requests

2 participants