Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tester-957 opened this issue Apr 26, 2024 · 3 comments

Comments

@Tester-957
Copy link

Tester-957 commented Apr 26, 2024

@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>
  1. 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

@HuakunShen
Copy link
Collaborator

HuakunShen commented Apr 28, 2024

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
Copy link

ChurchTao commented Apr 30, 2024

fix in ChurchTao/clipboard-rs#24
release soon.

@HuakunShen @Tester-957

@HuakunShen
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants