-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
After inserting the link, all words are also part of the link #2571
Comments
This already happens for automatically added links. Manually added links behave exactly like other marks (bold, italic, etc.) |
I don't understand why this is closed, it's still behaving in the way described by the issue, which feels like a bug. It's true that automatically added links work correctly, but it seems like it's not possible to make manually-added ones work right. The inclusive setting for links is connected to whether autolinking is on or not... if I turn off autolinking then it works correctly, but now I don't have autolinking. |
To be clear, the problem is that while - as you say @philippkuehn - the links behave like the other marks by having the link remain active at the end of the line after adding it, turning off the link does not work the same way as turning off those things. If I turn off bold in this situation, the text that I already bolded remains that way but new things I type are no longer bold. But if I turn off the link then it removes it altogether, so there is no way to remove yourself from the link without getting rid of the link. |
Me thinks too this could be reopened, or for the 2.0 release there could be a docs enhancement or change of default behaviour, as the changes by the automatic links make it hard or impossible to create/insert links at the end of a document and continue the paragraph non-linked. At least I haven't found a simple command chain that succeeded. Not a huge issue for me, as automatic links are no important feature for me and thanks to the issue creator I found this workaround (disabling autolink) |
@philippkuehn can you please show us the preferred method of inserting some text with a link and then untoggling the link mark so that subsequent text will not have the mark? The problem OP mentioned can be seen in your own Link demo: https://tiptap.dev/api/marks/link Just go to the end of the document, click "setLink", type some text, then click "unsetLink". The link will disappear. We were previously using:
to add some whitespace, then the desired link text (grabbed from a modal like the Slack link UI), then whitespace. The link was clickable but the mark was removed at the end of the text. However, this recently broke after a tiptap upgrade and we're trying to figure out the correct way to insert a bounded link mark now... |
Quick follow up to say this is working for us:
where |
We're also bumping into this issue. It's surprising to me that the docs explain that |
For those finding this issue, you can get around the autolink/inclusive options being tied like so:
|
Thanks so much for this! 😭 🙌 |
@duhaime Your suggestion wasn't working for me as of 12/01/2024. This is what ended up working, courtesy of ChatGPT :) editor
.chain()
.focus()
.extendMarkRange("link")
.command(({ tr, dispatch }) => {
if (!dispatch) return true;
const { from, to } = tr.selection;
const displayText = values.displayText || values.url || "";
tr.insertText(displayText, from, to);
tr.addMark(
from,
from + displayText.length,
editor.schema.marks.link.create({ href: values.url }),
);
return true;
})
.run(); |
What’s the bug you are facing?
If you insert a link in the text of the description, all subsequent words continue to be part of the hyperlink.
How can we reproduce the bug on our side?
Can you provide a CodeSandbox?
No response
What did you expect to happen?
That after inserting a link and pressing a space, the word is not part of the link
Anything to add? (optional)
No response
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: