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
Implement simple link decoration in richtext fields #4397
Conversation
⛔ Feature branch deployment currently inactive.If the PR is still open, you can add the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, great stuff! Will test manually later.
rel: 'noopener noreferrer', | ||
} | ||
if (this.editor.isEditable) { | ||
attrs.onclick = `(event.metaKey || event.ctrlKey) && window.open("${link}", "_blank");` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two inputs:
-
I like the idea that you have to use
Ctrl + Click
to follow the link, but I'm unsure if all users will discover this themselves. Let's see (I would leave it like this for now) -
Ctrl + Click
is already used by Tiptap. The text-edit dialog (bold, italic) is then displayed. Maybe you can stop this withevent.stopPropagation()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I like the idea that you have to use Ctrl + Click to follow the link, but I'm unsure if all users will discover this themselves. Let's see (I would leave it like this for now)
Sadly the browser prevents the click if it is inside a contenteditable
. That's why I've added the click handler. I've also made it possible to doubleclick the link to open it.
- Ctrl + Click is already used by Tiptap. The text-edit dialog (bold, italic) is then displayed. Maybe you can stop this with event.stopPropagation().
I was able to prevent the bubble menu if you click or select within/whole link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my tests the tiptap menu still opens on ctrl + click.
I would say we improve that in the next iterations.
very cool
# Conflicts: # frontend/package-lock.json # frontend/package.json
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
It has been requested several times to be able to click links. To reduce this pain we provide a simple prosemirror plugin that highlights all links automatically. The link text can't be changed to something more readable and the link as an element is not saved to the database (doesn't modify the editor storage)
This is only a small step towards an eventual smartlink, but it is the minimal valuable product.
This uses the linkify-it package used by markdown-it maintainers. It also provides support for fuzzy links (e.g. without
http://
) An example can be seen here: https://markdown-it.github.io/linkify-it/We only support
http
and 'https' protocols and fuzzy links with a known tld (.ch
,.com
,.org
,…) or then the link needs to have a port (localhost:3000
)The link is rendered as long as it is detected as a link and has no marks (e.g. bold). The url can only be changed with the keyboard, otherwise if you [ ctrl | cmd |
dbl
]-click on the link, it opens the link.Relates to #4241