I want to copy text as RTF, but Clipboard API seems not to support this format according to THIS.
I wrote following function to copy the text in form of plain text (second arg) and rtf (first arg). Tried html, but doesn't work, MS Word just takes all RTF stuff as plain text.
function copy(rtf, text) {
function listener(e) {
e.clipboardData.setData("text/plain", text);
e.clipboardData.setData("text/html", rtf);
e.preventDefault();
}
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
};
I have following types:
but there is no RTF. Is it possible to write my own type somehow?