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

Some problems with copying HTML fragments #32

Closed ayangweb closed 1 month ago

ayangweb commented 1 month ago

Hey 👋, the onTextUpdate event is triggered at the same time when copying the HTML content, is it possible to trigger only the onHTMLUpdate event!

image
HuakunShen commented 1 month ago

That's actually the intended behaviour. Copying HTML write two types of content to your clipboard.

For now, you could write your own custom listenToClipboard function https://github.com/CrossCopy/tauri-plugin-clipboard/blob/a45bd763571c1924feb7ef0fcef857fef8ad2927/webview-src/api.ts#L256-L259

If you return when HTML is detected, text event won't be triggered.

I will consider adding options to this function.

ayangweb commented 1 month ago

That's actually the intended behaviour. Copying HTML write two types of content to your clipboard.

For now, you could write your own custom listenToClipboard function

https://github.com/CrossCopy/tauri-plugin-clipboard/blob/a45bd763571c1924feb7ef0fcef857fef8ad2927/webview-src/api.ts#L256-L259

If you return when HTML is detected, text event won't be triggered.

I will consider adding options to this function.

Okay, thanks, I'll try this code

HuakunShen commented 1 month ago

Just added a breakOnType option for startListening() and listenToCliipboard(). Published version v1.0.0.

If you do this, text events will not be emited.

startListening({html: true})
ayangweb commented 1 month ago

Just added a breakOnType option for startListening() and listenToCliipboard(). Published version v1.0.0.

If you do this, text events will not be emited.

startListening({html: true})

Okay, thanks. I'll try it later.

HuakunShen commented 1 month ago

@ayangweb Sorry I just removed the breakOnType feature. It's not robust enough.

A new listener onSomethingUpdate is added. I recommend using this to listen for what types of content is updated, then decide which type to read yourself.

Discussed in https://github.com/CrossCopy/tauri-plugin-clipboard/issues/31

ayangweb commented 1 month ago

@ayangweb Sorry I just removed the breakOnType feature. It's not robust enough.

A new listener onSomethingUpdate is added. I recommend using this to listen for what types of content is updated, then decide which type to read yourself.

Discussed in #31

Okay, thank you author, hard work!