CrossCopy / tauri-plugin-clipboard

A Tauri clipboard plugin with text, files, html, RTF, and image support. Clipboard content update monitoring is also supported.
https://crosscopy.github.io/tauri-plugin-clipboard/
MIT License
122 stars 6 forks source link

Feature request: exposing the Clear() method #15

Closed hakoptak closed 7 months ago

hakoptak commented 7 months ago

Hi, thanks for this wonderful clipboard plugin.

Would it be possible to add a Clear() function to it? Or does it automatically clear after reading its contents?

HuakunShen commented 7 months ago

It doesn't clear clipboard after read. You can simply write empty data to clipboard to overwrite existing data. Use the writeText function.

hakoptak commented 7 months ago

Thanks for your suggestion.

If calling writeText() with empty data also clears any image or file path data then it is a workable solution (though an explicit clear() function would make the API more comprehensible).

HuakunShen commented 7 months ago

@hakoptak Yes writing an empty string to clipboard should clear image and text data. But if you have a clipboard history manager running, it will still keep track of the old clipboard data.

I could add a clear(), it's pretty simple. I will let you know when it's done.

hakoptak commented 7 months ago

Thanks for following up and thanks for willing to add this functionality.

HuakunShen commented 7 months ago

Done. https://github.com/CrossCopy/tauri-plugin-clipboard/pull/16 Used arboard's clear method instead of write text. Should be the same things.