Skip to content

Commit

Permalink
fix(link): Prevent middle-click from opening two tabs on Firefox
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Feb 28, 2024
1 parent 69fa349 commit bbfbfbe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/marks/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ const Link = TipTapLink.extend({
props: {
handleDOMEvents: {
// Open link in new tab on middle click
pointerup: (view, event) => {
auxclick: (view, event) => {
if (event.target.closest('a') && event.button === 1 && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
event.preventDefault()
event.stopImmediatePropagation()

const linkElement = event.target.closest('a')
window.open(linkElement.href, '_blank')
Expand Down

0 comments on commit bbfbfbe

Please sign in to comment.