Skip to content

Conversation

@Ovgodd
Copy link
Collaborator

@Ovgodd Ovgodd commented Oct 7, 2025

Purpose

Fix DnD of links
Before this fix: both drag-and-drop and copy/paste turned them into plain links, and it seems that there is a conflict with it

For copy-paste, the behavior is a bit weird: when you make a simple text selection, only the text is copied. You have to “over-select” with the arrow keys to include the link as well (see the video).

issue : 1351

dndcc.mp4

Proposal

  • Switch from <a> to <button>
@Ovgodd Ovgodd requested a review from AntoLC October 7, 2025 15:06
@Ovgodd Ovgodd self-assigned this Oct 7, 2025
@Ovgodd Ovgodd added bug Something isn't working frontend editor labels Oct 7, 2025
@Ovgodd Ovgodd changed the title ✨(frontend) preserve interlink style on drag-and-drop in editor 🐛 (frontend) preserve interlink style on drag-and-drop in editor Oct 7, 2025
@Ovgodd Ovgodd force-pushed the fix/1451-interlinking-drag-drop branch 2 times, most recently from ee19c21 to 8acf462 Compare October 7, 2025 15:08
@Ovgodd Ovgodd marked this pull request as ready for review October 7, 2025 15:08
@Ovgodd Ovgodd force-pushed the fix/1451-interlinking-drag-drop branch from 8acf462 to 2db509d Compare October 7, 2025 15:09
Copy link
Collaborator

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the root problem actually, here we use a StyledLink that render a a tag:

There is a conflict with the a tag, I think Blocknote or Tiptap take over our custom component during pasting or copy event.

An easy fix is to use a button tag instead of a a tag, like that we avoid the conflict, ex:

const LinkSelected = ({ url, title }: LinkSelectedProps) => { const { colorsTokens } = useCunninghamTheme(); const router = useRouter(); return ( <BoxButton onClick={(e) => { e.preventDefault(); router.push(url); }} draggable="false" $css={css`  display: inline;  padding: 0.1rem 0.4rem;  border-radius: 4px;  & svg {  position: relative;  top: 2px;  margin-right: 0.2rem;  }  &:hover {  background-color: ${colorsTokens['greyscale-100']};  }  transition: background-color 0.2s ease-in-out;  `} > <SelectedPageIcon width={11.5} /> <Text $weight="500" spellCheck="false" $size="16px" $display="inline"> {title} </Text> </BoxButton> ); };
@Ovgodd
Copy link
Collaborator Author

Ovgodd commented Oct 9, 2025

I found the root problem actually, here we use a StyledLink that render a a tag:

There is a conflict with the a tag, I think Blocknote or Tiptap take over our custom component during pasting or copy event.

An easy fix is to use a button tag instead of a a tag, like that we avoid the conflict, ex:

const LinkSelected = ({ url, title }: LinkSelectedProps) => { const { colorsTokens } = useCunninghamTheme(); const router = useRouter(); return ( <BoxButton onClick={(e) => { e.preventDefault(); router.push(url); }} draggable="false" $css={css`  display: inline;  padding: 0.1rem 0.4rem;  border-radius: 4px;  & svg {  position: relative;  top: 2px;  margin-right: 0.2rem;  }  &:hover {  background-color: ${colorsTokens['greyscale-100']};  }  transition: background-color 0.2s ease-in-out;  `} > <SelectedPageIcon width={11.5} /> <Text $weight="500" spellCheck="false" $size="16px" $display="inline"> {title} </Text> </BoxButton> ); };

Oh yes nice, and with that we can get rid of my useInterlinkDropNormalizer hook :o ! this is simpler ahha and it works

@Ovgodd Ovgodd force-pushed the fix/1451-interlinking-drag-drop branch from 443a07c to f22ce40 Compare October 9, 2025 10:06
@Ovgodd Ovgodd requested a review from AntoLC October 9, 2025 10:07
@Ovgodd Ovgodd force-pushed the fix/1451-interlinking-drag-drop branch 2 times, most recently from 0e0f9de to 3cf10e8 Compare October 9, 2025 11:34
adds hook to normalize dropped blocks and restore internal link format Signed-off-by: Cyril <c.gromoff@gmail.com>
@Ovgodd Ovgodd force-pushed the fix/1451-interlinking-drag-drop branch from 3cf10e8 to 91eba31 Compare October 9, 2025 11:40
@Ovgodd Ovgodd merged commit 91eba31 into main Oct 9, 2025
20 of 22 checks passed
@Ovgodd Ovgodd deleted the fix/1451-interlinking-drag-drop branch October 9, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working editor frontend

3 participants