ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
26.6k stars 2.23k forks source link

[Bug]: extendMarkRange doesn't work selecting first character #4237

Open timfuhrmann opened 1 year ago

timfuhrmann commented 1 year ago

Which packages did you experience the bug in?

react, extension-link

What Tiptap version are you using?

2.0.4

What’s the bug you are facing?

Selecting the first character of a link and calling extendMarkRange("link").unsetLink().run() will only unset the link for the first character - selecting any other character and calling said chain of functions will completely remove the link, as expected. Same behavior for other extensions like bold or italic - it seems that extendMarkRange is not working properly selecting the first character only.

What browser are you using?

Chrome

Code example

https://codesandbox.io/s/laughing-ardinghelli-g255xt?file=/src/App.js

What did you expect to happen?

Since extendMarkRange is being called the link should be remove completely.

Anything to add? (optional)

How To Reproduce

  1. Select first character of a link
  2. Click unsetLink

Did you update your dependencies?

Are you sponsoring us?

gilmarsquinelato commented 11 months ago

Hello everyone!

This bug is happening to me as well.

Even by simply running editor.chain().focus().extendMarkRange('link').run() you can see how it's behaving.

If the selection only contains part of the text but not the first character, it works perfectly. If the selection contains the first character (it doesn't need to be only the first character) but isn't the entire link range, it doesn't extend the selection.

I hope this information helps you to find the root cause :)