2

We are using a 3D CAD application which allows to copy the 3D data in a special format to the clipboard. We now want to paste this 3D data (basically it's structured as XML) in the browser.

I tried a lot with the HTML5 Clipboard API, but besides text and HTML nothing works, the clipboardData is always emtpy...

Even if I log the type, besides text and HTML, it's empty: console.log(event.clipboardData.types);

Retrieving data with event.clipboardData.getData('application/x-egr-eai-basket-cutbuffer-uncompressed') doesn't work, too.

Is it even possible to paste such a custom format in the browser?

1 Answer 1

2

It seems custom data formats for the clipboard are not directly supported. According to the specification in W3C:

If data type is text/plain:

  1. Ensure encoding is correct per OS and locale conventions
  2. Normalize line endings according to platform conventions
  3. Place text on clipboard with the appropriate OS clipboard format description

Otherwise, if data is of a type listed in the mandatory data types list

Place part on clipboard with the appropriate OS clipboard format description

Otherwise

This is left to the implementation..

This suggests to me that any custom types will be ignored by browsers. As such, I'd advise simply saving the XML as a string to the clipboard and retrieving it using event.clipboardData.getData('text/plain')

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I was reading the same specification and already feared that it is like it is. Using text/plain isn't working, maybe because of the way the 3D applications puts the contents into the clipboard (not as text). But thanks anyway, now it seems clearer to me.
@AndreasRemdt. Maybe log this as an issue on the 3D application's forum. It may be a common issue with that application, and they may have workarounds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.