PDA

View Full Version : [OPEN-417][3.1] Unable to right click paste into htmleditor



supercharge2
6 Jan 2010, 10:05 AM
I just caught a strange problem with the htmleditor. Since moving to 3.1.0 from 3.0.0 my users were unable to save there problem/resolution notes (this is a help desk app). I always do CTRL-V myself so when I would test it, it always worked fine for me. I finally realized they all were right clicking and choosing paste from the browsers context menu. When its pasted that way the text never even submits, only CTRL-V from the keyboard works. This also goes for the browser menu edit/paste as well. This is happening in Firefox 3.5.6 and IE 8. Any workarounds to this would be much appreciated.

supercharge2
12 Jan 2010, 11:51 AM
So, no one uses this component? Here is a simple example if your not using it:



Ext.onReady(function () {
var form = new Ext.form.FormPanel({
baseCls: 'x-plain',
labelWidth: 55,
url: 'save-form.php',
defaultType: 'textfield',
items: [{
fieldLabel: 'Send To',
name: 'to',
anchor: '100%' // anchor width by percentage
},
{
fieldLabel: 'Subject',
name: 'subject',
anchor: '100%' // anchor width by percentage
},
{
xtype: 'htmleditor',
hideLabel: true,
name: 'msg',
anchor: '100% -53' // anchor width by percentage and height by raw adjustment
}]
});
var window = new Ext.Window({
title: 'Resize Me',
width: 500,
height: 300,
minWidth: 300,
minHeight: 200,
layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'center',
items: form,
buttons: [{
text: 'Send',
handler: function () {
form.getForm().submit();
}
},
{
text: 'Cancel'
}]
});
window.show();
});


Now just copy something from your email/web page and right click paste it into the htmleditor then submit and look at firebug. You will see that doesn't pass the contents of the htmleditor. Reload and try doing a CTRL-V in the box and now you see that it passes the information.

hjf1223
6 Apr 2010, 9:39 PM
I have the same problem.

hjf1223
6 Apr 2010, 10:04 PM
The following code works for me, but I think there has better solution.



Ext.override(Ext.form.HtmlEditor, {
// private
initEditor: function() {
//Destroying the component during/before initEditor can cause issues.
try {
var dbody = this.getEditorBody();
var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
ss['background-attachment'] = 'fixed'; // w3c
dbody.bgProperties = 'fixed'; // ie

Ext.DomHelper.applyStyles(dbody, ss);

if (this.doc) {
try {
Ext.EventManager.removeAll(this.doc);
} catch (e) { }
}

this.doc = this.getDoc();
Ext.EventManager.on(this.doc, {
'mousedown': this.onEditorEvent,
'dblclick': this.onEditorEvent,
'click': this.onEditorEvent,
'keyup': this.onEditorEvent,
'mouseout': function() { this.syncValue(); }, // to fix the issue.
buffer: 100,
scope: this
});

if (Ext.isGecko) {
Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
}
if (Ext.isIE || Ext.isWebKit || Ext.isOpera) {
Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
}
this.initialized = true;
this.fireEvent('initialize', this);
this.doc.editorInitialized = true;
this.pushValue();
} catch (e) { }
}
}