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

Markdig-based MarkdownTextBlock doesn't support clicking hyperlinks #584

Open
Arlodotexe opened this issue Nov 2, 2024 · 2 comments · May be fixed by #588
Open

Markdig-based MarkdownTextBlock doesn't support clicking hyperlinks #584

Arlodotexe opened this issue Nov 2, 2024 · 2 comments · May be fixed by #588
Labels
enhancement Improvement to an existing feature

Comments

@Arlodotexe
Copy link
Member

Looking through the new Markdig-based Markdown control, I'm not seeing any obvious way to handle clicked links in the consuming application.

I see the library has an AutoLinkParser that takes an AutoLinkOptions.OpenInNewWindow, but AutoLink seems to be centered around detecting and making raw links clickable in the renderer. It's not clear where or how link clicks are handled from code-behind.

Looking at another UI project that uses Mardig, markdig.wpf, we find that their sample app is routing "hyperlink clicks" through FrameworkElement CommandBindings. Digging further, they've connected this binding through a Hyperlink object that is passed to a custom wpf-based LinkInlineRenderer.

We'll need to create a similar custom link renderer in the MarkdownTextBlock control offered in Labs before we can move forward with this ticket.

Originally posted by @Arlodotexe in #512

@Arlodotexe Arlodotexe added the enhancement Improvement to an existing feature label Nov 2, 2024
@Arlodotexe Arlodotexe changed the title Mardig-based MarkdownTextBlock doesn't support clicking hyperlinks Markdig-based MarkdownTextBlock doesn't support clicking hyperlinks Nov 2, 2024
@Arlodotexe Arlodotexe moved this to 🆕 New in Toolkit 8.x Nov 2, 2024
@michael-hawker
Copy link
Member

michael-hawker commented Nov 5, 2024

Think these are the TODOs that are missing for this feature?

public void AddChild(IAddChild child)
{
#if !WINAPPSDK
if (child.TextElement is Windows.UI.Xaml.Documents.Inline inlineChild)
{
try
{
_hyperlink.Inlines.Add(inlineChild);
// TODO: Add support for click handler
}
catch { }
}
#else
if (child.TextElement is Microsoft.UI.Xaml.Documents.Inline inlineChild)
{
try
{
_hyperlink.Inlines.Add(inlineChild);
// TODO: Add support for click handler
}
catch { }
}
#endif
}

@nerocui is that correct? What's the difference between the Hyperlink and HyperlinkButton here?

@nerocui
Copy link
Contributor

nerocui commented Nov 8, 2024

Both HyperLink and HyperLinkButton should support clicking event if the URI is setup correctly. The TODO is there because I wanted to support the case where the developer want to handle the event with custom logic. Like opening in other apps, adding additional logic or in case the URI is not standard web URL.

@Arlodotexe Arlodotexe linked a pull request Nov 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

3 participants