herronial
03-26-2006, 01:04 PM
Hi,
I'm trying to customize a wysiwyg editor (the widgEditor). It's setup to automatically clean any html that is pasted in the textarea. However it only detects the pasted content if you use 'Ctrl-V'. If you 'right-click paste' or click 'Edit-Paste' the content won't be automaticaaly cleaned.
Here is the code that detects the paste:
/* Check for pasted content */
widgEditor.prototype.detectPaste = function(e)
{
var keyPressed = null;
var theEvent = null;
if (e)
{
theEvent = e;
}
else
{
theEvent = event;
}
if (theEvent.ctrlKey && theEvent.keyCode == 86 && this.wysiwyg)
{
var self = this;
this.pasteCache = this.theIframe.contentWindow.document.getElementsByTagName("body")[0].innerHTML;
/* Because Mozilla can't access the clipboard directly, must rely on timeout to check pasted differences in main content */
setTimeout(function(){self.cleanSource(); return true;}, 100);
}
return true;
}
Anyone have any ideas how I could get the pasted content automatically cleaned no matter what method the user opts for?
cheers
I'm trying to customize a wysiwyg editor (the widgEditor). It's setup to automatically clean any html that is pasted in the textarea. However it only detects the pasted content if you use 'Ctrl-V'. If you 'right-click paste' or click 'Edit-Paste' the content won't be automaticaaly cleaned.
Here is the code that detects the paste:
/* Check for pasted content */
widgEditor.prototype.detectPaste = function(e)
{
var keyPressed = null;
var theEvent = null;
if (e)
{
theEvent = e;
}
else
{
theEvent = event;
}
if (theEvent.ctrlKey && theEvent.keyCode == 86 && this.wysiwyg)
{
var self = this;
this.pasteCache = this.theIframe.contentWindow.document.getElementsByTagName("body")[0].innerHTML;
/* Because Mozilla can't access the clipboard directly, must rely on timeout to check pasted differences in main content */
setTimeout(function(){self.cleanSource(); return true;}, 100);
}
return true;
}
Anyone have any ideas how I could get the pasted content automatically cleaned no matter what method the user opts for?
cheers