Skip to content
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

refactor: hyperlink extract common logic [TOL-1637] #1568

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

YvesRijckaert
Copy link
Contributor

No description provided.

@YvesRijckaert YvesRijckaert force-pushed the refactor/dry-richtext-hyperlink branch from 6f04ccb to e933820 Compare January 4, 2024 09:17
@YvesRijckaert YvesRijckaert marked this pull request as ready for review January 4, 2024 09:22
@YvesRijckaert YvesRijckaert requested a review from a team as a code owner January 4, 2024 09:22
Copy link
Contributor

@chrishelgert chrishelgert left a comment

Choose a reason for hiding this comment

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

Wondering if we can also have a base component?
So we only need to provide the handleEditLink, handleRemoveLink and the toooltipContent and the children to it? 🤔

@YvesRijckaert
Copy link
Contributor Author

Wondering if we can also have a base component? So we only need to provide the handleEditLink, handleRemoveLink and the toooltipContent and the children to it? 🤔

I tried something like that, but we are calling different hooks in all those components, the types are also different and there are other quirks (different data attributes, different forma components (link vs text), etc) It wasn't very readable in the end so I left it the way it is now

import { useSdkContext } from '../../../SdkProvider';

export function useHyperlinkCommon(element) {
const editor = useContentfulEditor();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'm not sure I see the benefits for editor and sdk feels like adding a layer of complexity rather than removing. isLinkFocused and pathToElement make sense

Copy link
Contributor

Choose a reason for hiding this comment

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

Please feel free to ignore though just my opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yes not sure, I think we need editor to calculate pathToElement

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right okay then

@YvesRijckaert YvesRijckaert merged commit 2410b7a into master Jan 4, 2024
14 checks passed
@YvesRijckaert YvesRijckaert deleted the refactor/dry-richtext-hyperlink branch January 4, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants