Closed ayangweb closed 1 month ago
This is the same as your other issue https://github.com/CrossCopy/tauri-plugin-clipboard/issues/32
Copying image from browser indeed triggers both html and image update.
I will add an option argument. For now you can implement your own listen function.
This is the same as your other issue #32
Copying image from browser indeed triggers both html and image update.
I will add an option argument. For now you can implement your own listen function.
Okay, thanks.
In https://github.com/CrossCopy/tauri-plugin-clipboard/issues/32 the HTML + text event issue is addressed with a breakOnType
option.
But I just realized, the design doesn't solve this one. The order of type checking is files -> image -> html -> rtf -> text.
If you break on image, html event will not be triggered. I will make another design. Or just write your custom listener, it's easier to deal with the order.
In v1.0.1
I added a onSomethingUpdate()
listener.
await onSomethingUpdate(async (updatedTypes) => {
console.log('updated types:', updatedTypes);
if (updatedTypes.html) {
console.log(await readHtml());
}
if (updatedTypes.image) {
const img = await readImageBase64()
}
});
You will get {files: false, image: false, html: true, rtf: false, text: true}
when you copy html and {files: false, image: true, html: true, rtf: false, text: false}
when you copy image in web page.
Do not call onHTMLUpdate
. Instead, read the content within the callback.
我
v1.0.1
添加了一个onSomethingUpdate()
听众。await onSomethingUpdate(async (updatedTypes) => { console.log('updated types:', updatedTypes); if (updatedTypes.html) { console.log(await readHtml()); } if (updatedTypes.image) { const img = await readImageBase64() } });
{files: false, image: false, html: true, rtf: false, text: true}
当您复制 html 和{files: false, image: true, html: true, rtf: false, text: false}
复制网页中的图像时,您将获得。不要调用
onHTMLUpdate
。而是读取回调中的内容。
Thanks author, I'll try it later, I'll be out here for a while! Thanks for your hard work.
In
v1.0.1
I added aonSomethingUpdate()
listener.await onSomethingUpdate(async (updatedTypes) => { console.log('updated types:', updatedTypes); if (updatedTypes.html) { console.log(await readHtml()); } if (updatedTypes.image) { const img = await readImageBase64() } });
You will get
{files: false, image: false, html: true, rtf: false, text: true}
when you copy html and{files: false, image: true, html: true, rtf: false, text: false}
when you copy image in web page.Do not call
onHTMLUpdate
. Instead, read the content within the callback.
I tried this and it does work, but I'm curious to ask Does rtf
mean rich text? What would it be triggered on?
Hey 👋, I searched for a random image from my browser and copied the image, but it triggered the
onHTMLUpdate
event at the same time! Can this be optimized? It should only trigger theonImageUpdate
event!