-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
TextStyle cannot be cleared when cursor is on new line #3702
Comments
I have the same problem. How can I solve it |
@bdbch, I've already started work on this. However, I need some guidance here It turns out there are two main factors that cause this behavior Factor 1We begin with the unset command of an extension that extends text-style. For example: font-family Note that it first calls Factor 2Chained commands fail to persist stored marks. Look at this code snippet; it looks like in between chained commands, we are resetting the transaction's stored marks based on what is in state: As a result, the storedMarks fields cannot be updated if you run more than one chained command. SolutionThe initial solution posted in this issue (to combine both commands into a single one) was able to resolve this issue because no subsequent commands are ran that would otherwise reset the stored mark. Removing the logic that resets the transaction stored marks for chained commands also resolves the issue. This seems like the solution to go with, but I really would need to know what prompted the change to begin with. All I have to go off of is this commit that I'm struggling to find an associated PR/issue for: |
How to solve the problem? |
@lzxlzxlzxl I'll submit a pull request with the above change sometime this week and hope to get a response about the solution through that |
What’s the bug you are facing?
When you have your cursor on a new line and some text style is applied (either from the Font Family or Color extensions), you cannot clear out the text styles when the cursor is on a new line.
Which browser was this experienced in? Are any special extensions installed?
Chrome Version 109.0.5414.75 (Official Build) (64-bit)
Extensions:
How can we reproduce the bug on our side?
For either the font-family or color extensions, scroll down to the text editor demos:
https://tiptap.dev/api/extensions/font-family
https://tiptap.dev/api/extensions/color
Can you provide a CodeSandbox?
No response
What did you expect to happen?
The text style should be removed from your stored marks even if the cursor is at the beginning of a new block
Anything to add? (optional)
I don't know why this issue only applies when the cursor is at the beginning of a new paragraph/block(?). It seems to be caused by weird interactions between
.setMark("textStyle", { myAttr: null })
and.removeEmptyTextStyle()
.Combining the two commands into a single custom transactional command seems to resolve this issue:
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: