I am working on a Kotlin multiplatform project.
I want to support copy action with formatting.
There are a plenty of page in the web implementing it in javascript. All of them are almost same and do it like this:
const content = "SOMETHING!"
const clipboardItem = new
ClipboardItem({
'text/html': new Blob([content],{type: 'text/html'}),
'text/plain': new Blob([content],{type: 'text/plain'})
});
navigator.clipboard.write([clipboardItem])
But I don’t know how should I implement it in Kotlin. Indeed, I could not construct an instance of ClipboardItem
. How should I do it?
The following is my incomplete snippet written in Kotlin:
navigator.clipboard.write(
arrayOf(
ClipboardItem( ..... ) // <--- What should be here?
)
)
Note that I’ve also asked the same question in SO.