I have a textarea that I want to paste different text formats into. What would be ideal is to have several buttons each with a different kind of label.. One button to paste format A, another to paste format B… Each of these formats is just text. the JavaScript psuedocode for these would be:
function pasteFormatA() {
var txt = clipboard.getTextContent();
if(txt) {
// sanitize text
// then put in textarea
}
}
Is that possible? Using Chrome, but cross browser solution would be better.
Reading the actual clipboard would be a violation of browser sandboxing. The best you can do is to sanitize the content after it is pasted.
This is a jQuery example of filtering based on active button pressed.
http://jsfiddle.net/xjTUY/1