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

There seems to be a limit to the length when writing to html. and will be automatically truncated. #29

Closed Tester-957 closed 2 months ago

Tester-957 commented 2 months ago

@HuakunShen Platform: Windows 11 Version: 0.6.8

I added some code to the example for testing:

  1. Read html and print the length into the htmlString variable

    <button
    type="button"
    class="btn variant-filled block btn-sm"
    on:click={() => {
        clipboard.readHtml().then((t) => {
            html = t;
            htmlString = t;
            console.info(`%cread HTML Length: ${htmlString.length}`, 'color: red');
            console.log(htmlString);
        });
    }}
    >
    Read HTML
    </button>
  2. Write htmlString unchanged to clipboard and read clipboard html length again

    
    <button
    type="button"
    class="btn variant-filled block btn-sm"
    on:click={async () => {
        await clipboard.writeHtml(htmlString);
        clipboard.readHtml().then((t) => {
            html = t;
            console.info(`%cwrite HTML Length: ${t.length}`, 'color: red');
            console.log(t);
        });
    }}
    >
    Write HTML
    </button>


result:
![image](https://github.com/CrossCopy/tauri-plugin-clipboard/assets/58334417/4ca1e070-dcaf-4cab-9811-e645d6740e8e)
HuakunShen commented 2 months ago

I did this experiment on Mac and Windows. Mac had no problem writing a large html, but windows couldn't handle large html.

use clipboard_rs::{ClipboardContext, Clipboard};

fn main() {
    let ctx = ClipboardContext::new().unwrap();
    let html = std::fs::read_to_string("./text.html").unwrap();
    println!("Length (original): {}", html.len());
    ctx.set_html(html).unwrap();
    let html = ctx.get_html().unwrap();
    println!("Length: {}", html.len());
}

stdout

Length (original): 132205
Length: 205

Reading html on Windows works. Reading and writing on Ubuntu work.

ChurchTao commented 2 months ago

fix in https://github.com/ChurchTao/clipboard-rs/pull/24 release soon.

@HuakunShen @Tester-957

HuakunShen commented 2 months ago

https://github.com/CrossCopy/tauri-plugin-clipboard/releases/tag/v0.6.9