I could be wrong, but I think the code could still use improvement. The executeCommand method returns "undefined" in IE if "Paste via script" is disabled. This does NOT throw an error, so you never get the message. Because of this it took me a while to figure out what was going on in our environment because when pasting nothing would happen (no error, no alert) when PasteMode was set to Default.
Original Code:case FTB_PASTE_DEFAULT:
try{
this.ExecuteCommand('paste');
}catch(e){
alert('message...');
}
return true;
Possible Improvement:
case FTB_PASTE_DEFAULT:
try{
if(!this.ExecuteCommand('paste')) alert('message...');
}catch(e){
alert('message...');
}
return true;
Likewise the FTP_PASTE_TEXT does not seem to test for this condition ("Paste via script" set to disabled). The behavoir there is for a javascript error to be thrown, but then pasting as usual to occur (i.e. HTML included). At least an error was thrown there for me to know something was wrong, but an informative message would help developers out a lot.
Original Code:if(window.clipboardData){
//work
}else{
alert('Your browser does not support rich text pasting');
}
Possible Improvement:if(typeOf clipboardData == 'undefined'){
alert('Your browser does not support rich text pasting');
}else if(clipboardData.getData('Text') == 'undefined'){
alert('Your browser is set to DENY scripted pasting');
}else{
//do work
}
Additionally, I see this as a bug... because the only way to paste in a ftb with the browser set to disable scripted pasting is to set it PasteMode to Text, causing the error, which then actually diverts the method to NON Text only pasting. I think there should be a way to set it to "Do not handle scripting" or something like that, and for the alerts detecting the browser being set to disable scripted pasting to inform the developer that they must use this setting. An even better solution would be to somehow work around the problem. Because ftb's onClientTextChanged event does not gracefully execture when you are also changing the text (wordClean onTextChanged, then write back to the ftb) AND there is no blur event to do it after the user blurs, this is very problematic. The only options I see are to clean the text boxes up on submit click and letting the user know if any changes were made so they can review the outcome prior to final submit.
I for one would like to see a onBlur event added as well. This could come in handy for many reasons.
Thanks for a great product that works great in most configurations.