Skip to content

Conversation

@Biztactix-Ryan
Copy link

Sorry, I haven't written the tests for it... But this essentially allows you to get the URL as well as the copied text and HTML from browsers, which is rather useful.

I have tested it in Chrome 114.0.5735.199, Firefox 115.0.1 and Edge 114.0.1823.67
Works the same on all of them.

@Willy-Kimura
Copy link
Owner

Great feature! Html format detection can be a great value-add for a number of use cases.

However I'm seeing a breaking change from the current setup where both plain and html copied texts are both categorized as ContentTypes.Text. Probably to sweeten how it would typically work we can have a ContentFormats enumeration that would allow one to drill-down to the precise format of the content copied, e.g in this case ContentFormats.Html or if plain text ContentFormats.PlainText. The resulting feature would then look something similar to this:

if (e.ContentType == SharpClipboard.ContentTypes.Text)
{
    // You can simply get the content in plain text format...
    Debug.WriteLine(clipboard.ClipboardText);   // or e.Content.ToString()

    // or better yet get the Html format...
    if (e.ContentFormat == ContentFormats.Html)
    {
        // Cast copied content to HtmlData.
        var html = (HtmlData)e.Content;

        Debug.WriteLine(html.SelectedHtml);
    }
}

Let me know how we can improve on this. Many thanks!

@Biztactix-Ryan
Copy link
Author

Biztactix-Ryan commented Sep 8, 2023 via email

@Willy-Kimura
Copy link
Owner

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants