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: Support for Rich Text Format #11

Closed lively-ops closed 4 months ago

lively-ops commented 10 months ago

Thank you for the awesome plugin. It would be perfect if you could add formatted text/rtf format as well.

HuakunShen commented 10 months ago

@lively-ops I wanted to add this as well, but for now I don't have an idea how to achieve it.

Any suggestions?

HuakunShen commented 10 months ago

Electron's clipboard APIs seems to come from this file https://github.com/electron/electron/blob/main/shell/common/api/electron_api_clipboard.cc

But I am unable to find the depdency files.

Will look into this when I got time.

lively-ops commented 10 months ago

I think we will have to use winapi and cocoa crate for macOS and Windows and x11 or wayland libraries for linux.

For cross-platform support we can use conditional compilation to include platform-specific code.

lively-ops commented 10 months ago

For Windows, found these in winapi crate: https://docs.rs/winapi/latest/winapi/um/winuser/fn.SetClipboardData.html https://docs.rs/winapi/latest/winapi/shared/wtypes/struct.userCLIPFORMAT.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.SetClipboardData.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.RegisterClipboardFormatW.html https://docs.rs/winapi/latest/winapi/um/winuser/fn.RegisterClipboardFormatA.html

Reference for Windows API: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclipboardformatw

For MacOS:

https://docs.rs/cocoa/latest/cocoa/appkit/enum.NSPasteboardWritingOptions.html

For Linux:

https://docs.rs/x11/2.3.1/x11/xlib/struct.XSelectionEvent.html#structfield.selection (X11) https://docs.rs/wayland-client/0.29.0/wayland_client/protocol/wl_data_device/enum.Request.html#variant.SetSelection (Wayland)

HuakunShen commented 7 months ago

I will work on this. Just got clipboard files working.

ChurchTao commented 5 months ago

Electron's clipboard APIs seems to come from this file https://github.com/electron/electron/blob/main/shell/common/api/electron_api_clipboard.cc

But I am unable to find the depdency files.

Will look into this when I got time.

The API of electron is called chromium at the bottom level.

https://source.chromium.org/chromium/chromium/src/+/main:ui/base/clipboard/clipboard_mac.mm;l=276

I recently planned to use rust to write a low-level library similar to the Electron clipboard API, which is related to the low-level system API calls mentioned above.

ChurchTao commented 5 months ago

To be honest, the arboard library is not particularly well written, and no one is maintaining it. I am going to write one myself.

HuakunShen commented 5 months ago

To be honest, the arboard library is not particularly well written, and no one is maintaining it. I am going to write one myself.

Thanks! Let me know when you write it, I am happy to change the clipboard dependency.

ChurchTao commented 5 months ago

@HuakunShen I have already built the library, but it is still under development. macOS has been developed, and I am currently developing Windows and Linux. Can you please take a look at my API first? I estimate that I will complete it in about a month, and I hope that listen to other people's opinions

https://github.com/ChurchTao/clipboard-rs

HuakunShen commented 5 months ago

@ChurchTao Great, I will take a look. Thanks! I also sent you an email (gmail).

HuakunShen commented 4 months ago

HTML and RTF supported in v0.6.0 with clipboard-rs.