{"id":13466567,"url":"https://github.com/CopyText/TextCopy","last_synced_at":"2025-03-25T21:32:30.851Z","repository":{"id":37867137,"uuid":"144966848","full_name":"CopyText/TextCopy","owner":"CopyText","description":"A cross platform package to copy text to and from the clipboard.","archived":false,"fork":false,"pushed_at":"2024-10-28T07:34:56.000Z","size":1500,"stargazers_count":513,"open_issues_count":6,"forks_count":41,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-10-29T19:19:31.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CopyText.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":null},"created_at":"2018-08-16T09:30:19.000Z","updated_at":"2024-10-28T15:50:59.000Z","dependencies_parsed_at":"2023-10-03T16:46:58.906Z","dependency_job_id":"5ed091b1-9a89-4067-a5f6-1f82e4e4aec8","html_url":"https://github.com/CopyText/TextCopy","commit_stats":{"total_commits":923,"total_committers":15,"mean_commits":61.53333333333333,"dds":0.6132177681473456,"last_synced_commit":"012cbb44ad258581c3472fc1925aed0e324218ab"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopyText%2FTextCopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopyText%2FTextCopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopyText%2FTextCopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CopyText%2FTextCopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CopyText","download_url":"https://codeload.github.com/CopyText/TextCopy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245548568,"owners_count":20633611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:00:46.467Z","updated_at":"2025-03-25T21:32:30.259Z","avatar_url":"https://github.com/CopyText.png","language":"C#","funding_links":[],"categories":["Libraries \u0026 Extensions","others"],"sub_categories":["Tools \u0026 Utilities"],"readme":"# \u003cimg src=\"/src/icon.png\" height=\"30px\"\u003e TextCopy\n\n[![Build status](https://ci.appveyor.com/api/projects/status/35uq76nlt9tl6m3t/branch/master?svg=true)](https://ci.appveyor.com/project/SimonCropp/textcopy)\n[![NuGet Status](https://img.shields.io/nuget/v/TextCopy.svg)](https://www.nuget.org/packages/TextCopy/)\n\nA cross platform package to copy text to and from the clipboard.\n\n**See [Milestones](../../milestones?state=closed) for release notes.**\n\n\n## NuGet package\n\nhttps://nuget.org/packages/TextCopy/\n\n\n## Usage\n\n\n### SetTextAsync\n\n\u003c!-- snippet: SetTextAsync --\u003e\n\u003ca id='snippet-SetTextAsync'\u003e\u003c/a\u003e\n```cs\nawait ClipboardService.SetTextAsync(\"Text to place in clipboard\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L34-L38' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SetTextAsync' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### SetText\n\n\u003c!-- snippet: SetText --\u003e\n\u003ca id='snippet-SetText'\u003e\u003c/a\u003e\n```cs\nClipboardService.SetText(\"Text to place in clipboard\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L9-L13' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SetText' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### GetTextAsync\n\n\u003c!-- snippet: GetTextAsync --\u003e\n\u003ca id='snippet-GetTextAsync'\u003e\u003c/a\u003e\n```cs\nvar text = await ClipboardService.GetTextAsync();\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L43-L47' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-GetTextAsync' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### GetText\n\n\u003c!-- snippet: GetText --\u003e\n\u003ca id='snippet-GetText'\u003e\u003c/a\u003e\n```cs\nvar text = ClipboardService.GetText();\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L25-L29' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-GetText' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Clearing The Clipboard\n\n\u003c!-- snippet: ClearClipboard --\u003e\n\u003ca id='snippet-ClearClipboard'\u003e\u003c/a\u003e\n```cs\nClipboardService.SetText(\"\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L52-L54' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ClearClipboard' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\u003c!-- snippet: ClearClipboardAsync --\u003e\n\u003ca id='snippet-ClearClipboardAsync'\u003e\u003c/a\u003e\n```cs\nawait ClipboardService.SetTextAsync(\"\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L59-L61' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-ClearClipboardAsync' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Instance API\n\nIn addition to the above static API, there is an instance API exposed:\n\n\u003c!-- snippet: SetTextInstance --\u003e\n\u003ca id='snippet-SetTextInstance'\u003e\u003c/a\u003e\n```cs\nClipboard clipboard = new();\nclipboard.SetText(\"Text to place in clipboard\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Snippets.cs#L15-L20' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SetTextInstance' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Dependency Injection\n\nAn instance of `Clipboard` can be injected into `IServiceCollection`:\n\n\u003c!-- snippet: InjectClipboard --\u003e\n\u003ca id='snippet-InjectClipboard'\u003e\u003c/a\u003e\n```cs\nserviceCollection.InjectClipboard();\n```\n\u003csup\u003e\u003ca href='/src/BlazorSample/Program.cs#L9-L11' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-InjectClipboard' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nThe instance should be injected by using `IClipboard`.\n\nThere is also a `InjectMockClipboard` that injects an instance of `MockClipboard` with all methods stubbed out.\n\n\n## Supported on\n\n * Windows with .NET Framework 4.6.1 and up\n * Windows with .NET Core 2.0 and up\n * Windows with Mono 5.0 and up\n * OSX with .NET Core 2.0 and up\n * OSX with Mono 5.20.1 and up\n * Linux with .NET Core 2.0 and up\n * Linux with Mono 5.20.1 and up\n * Xamarin.Android 9.0 and up\n * Xamarin.iOS 10.0 and up\n * Blazor WebAssembly 6.0 and up\n\n\n## Blazor WebAssembly\n\nDue to the dependency on `JSInterop` the static `ClipboardService` is not supported on Blazor.\n\nInstead inject an `IClipboard`:\n\n\u003c!-- snippet: BlazorStartup --\u003e\n\u003ca id='snippet-BlazorStartup'\u003e\u003c/a\u003e\n```cs\nvar builder = WebAssemblyHostBuilder.CreateDefault();\nvar serviceCollection = builder.Services;\nserviceCollection.InjectClipboard();\nbuilder.RootComponents.Add\u003cApp\u003e(\"app\");\n```\n\u003csup\u003e\u003ca href='/src/BlazorSample/Program.cs#L6-L13' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-BlazorStartup' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nThen consume it:\n\n\u003c!-- snippet: Inject --\u003e\n\u003ca id='snippet-Inject'\u003e\u003c/a\u003e\n```cs\npublic partial class IndexModel :\n    ComponentBase\n{\n    [Inject]\n    public IClipboard Clipboard { get; set; }\n\n    public string Content { get; set; }\n\n    public Task CopyTextToClipboard() =\u003e\n        Clipboard.SetTextAsync(Content);\n\n    public async Task ReadTextFromClipboard() =\u003e\n        Content = await Clipboard.GetTextAsync();\n}\n```\n\u003csup\u003e\u003ca href='/src/BlazorSample/Pages/IndexModel.cs#L9-L24' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Inject' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nBlazor support requires the browser APIs [clipboard.readText](https://caniuse.com/#feat=mdn-api_clipboard_readtext) and [clipboard.writeText](https://caniuse.com/#feat=mdn-api_clipboard_writetext).\n\n\n## Linux\n\nLinux uses [xsel](https://github.com/kfish/xsel) to access the clipboard. As such it needs to be installed and callable.\n\n\n## Icon\n\n[Clone](https://thenounproject.com/term/Clone/207435/) designed by [Wes Breazell](https://thenounproject.com/wes13/) from [The Noun Project](https://thenounproject.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCopyText%2FTextCopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCopyText%2FTextCopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCopyText%2FTextCopy/lists"}