I have a requirement where a text copied onto the clipboard, has to be transformed into some other text before it gets pasted. E.g on button click I do a clipboard copy programmatically and some text like "Before Change" gets copied onto the clipboard. The paste event which I have tied to my editor cannot change the clipboard data and its always the data existing on the clipboard ("Before Change") that gets copied.
$("#Editor1").on("paste", createIncludedScriptPath);
function createIncludedScriptPath(e) {
var pastedData = e.originalEvent.clipboardData.getData('text');
var path = createPath(pastedData);
textToCopy = "." + " " + "'" + path + "'";
copyTextToClipboard(textToCopy);
}
Here, in the above code, I am trying to get the existing clipboard data, change it and copy the changed data on the clipboard. However, it is always the old data i.e. (in the pastedData variable) which gets pasted.
I learnt, that in the clipboard paste API, you cannot reset the clipboard.
How do I update the clipboard data, so that the updated data gets eventually pasted?
.value
of editable box. Don't forget to putpreventDefault()
– Naman Kheterpal