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]: getMarkRange returned an incorrect value #5715

Closed
1 task done
guanriyue opened this issue Oct 10, 2024 · 1 comment · Fixed by #5717
Closed
1 task done

[Bug]: getMarkRange returned an incorrect value #5715

guanriyue opened this issue Oct 10, 2024 · 1 comment · Fixed by #5717
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

@guanriyue
Copy link

Affected Packages

core

Version(s)

2.8.0

Bug Description

I recorded a video to demonstrate this bug.

2024-10-10.11.57.52.mov

As shown in the figure, clicking the link icon will select the entire link. This is achieved by using editor.commands.extendMarkRange('link')

截屏2024-10-10 11 52 33

It works as expected

截屏2024-10-10 11 55 04

But if the selection is like the one below, it will not work as expected

截屏2024-10-10 12 02 10

This problem only occurs when the $from of the selection is at the beginning of the link
After debugging I found out that this is because getMarkRange returns undefined

截屏2024-10-10 12 04 31 截屏2024-10-10 12 05 08

And if I change the first parameter of getMarkRange from $from to $to I can get it to work correctly.

I use the following code to meet my needs. But I prefer the simple editor.commands.extendMarkRange('link')

      const range = getMarkRange(
        editor.state.selection.$to,
        editor.schema.marks.link,
      );

      if (range) {
        editor.commands.setTextSelection(range);
        setPopover('link');
      }

Hope this problem can be solved

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

getMarkRange returns correct range.

Additional Context (Optional)

No response

Dependency Updates

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

This is released with v2.9.0

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

Successfully merging a pull request may close this issue.

2 participants