jcwatson11
3 Aug 2007, 12:12 AM
Hello all,
I think it might be a good idea to wait to enable the sourceedit toolbar button in the HtmlEditor until the editor is initialized. I ran into an error where the HtmlEditor will resize itself to about 50px high (width apparently not affected) when the source edit button is clicked.
Here's my code and steps for how to reproduce.
// construct the editor and apply it to email_body field.
var ebody_editor = new Ext.form.HtmlEditor({name: 'email_body',value: ''});
ebody_editor.on("initialize",function () {
var resizer = new Ext.Resizable(ebody_editor.getResizeEl(),{handles:"e,s,se",minWidth:600,minHeight:300});
ebody_editor.getResizeEl().on('resize',function() {
ebody_editor.setSize(ebody_editor.wrap.getSize());
});
});
ebody_editor.on("editmodechange",function () {
ebody_editor.setSize(ebody_editor.wrap.getSize());
});
ebody_editor.on("activate",function() {
if(ebody_editor.getValue()=='') {
ebody_editor.setValue('');
}
});
ebody_editor.applyTo('email_body');
Create a button on the page that will enter text into the HtmlEditor before it is initialized.
Create a textarea HTML element on your page with a name and id of email_body.
Use my code to turn the text area into an HtmlEditor with resizable features.
Use your button to add your text to the HtmlEditor before the HtmlEditor is clicked/initialized.
Now click on the sourceedit button. If it works like mine on IE 7, the HtmlEditor will resize itself to about 50px high.
Simply disabling the sourceedit button by default, and then initializing it when the HtmlEditor is initialized would fix this problem.
I found the code in the source in the definition for the onRender function definition:
this.tb.items.each(function(_15){if(_15.id!="sourceedit"){_15.disable();}});
If this line were changed to:
this.tb.items.each(function(_15){_15.disable();});
the problem would be gone.
Just out of curiosity, it appears that the code editor button is intentionally left enabled. I'm guessing there must be a reason. But it escapes me.
BTW: I'm using Ext1.1
Alternatively, I suppose the real question is, why does the component resize when the sourceedit button is clicked? Maybe that's the real fix. Come to think of it, in an ideal world, there should be no reason the source edit button *shouldn't* be available, except to fix this bug.
I think it might be a good idea to wait to enable the sourceedit toolbar button in the HtmlEditor until the editor is initialized. I ran into an error where the HtmlEditor will resize itself to about 50px high (width apparently not affected) when the source edit button is clicked.
Here's my code and steps for how to reproduce.
// construct the editor and apply it to email_body field.
var ebody_editor = new Ext.form.HtmlEditor({name: 'email_body',value: ''});
ebody_editor.on("initialize",function () {
var resizer = new Ext.Resizable(ebody_editor.getResizeEl(),{handles:"e,s,se",minWidth:600,minHeight:300});
ebody_editor.getResizeEl().on('resize',function() {
ebody_editor.setSize(ebody_editor.wrap.getSize());
});
});
ebody_editor.on("editmodechange",function () {
ebody_editor.setSize(ebody_editor.wrap.getSize());
});
ebody_editor.on("activate",function() {
if(ebody_editor.getValue()=='') {
ebody_editor.setValue('');
}
});
ebody_editor.applyTo('email_body');
Create a button on the page that will enter text into the HtmlEditor before it is initialized.
Create a textarea HTML element on your page with a name and id of email_body.
Use my code to turn the text area into an HtmlEditor with resizable features.
Use your button to add your text to the HtmlEditor before the HtmlEditor is clicked/initialized.
Now click on the sourceedit button. If it works like mine on IE 7, the HtmlEditor will resize itself to about 50px high.
Simply disabling the sourceedit button by default, and then initializing it when the HtmlEditor is initialized would fix this problem.
I found the code in the source in the definition for the onRender function definition:
this.tb.items.each(function(_15){if(_15.id!="sourceedit"){_15.disable();}});
If this line were changed to:
this.tb.items.each(function(_15){_15.disable();});
the problem would be gone.
Just out of curiosity, it appears that the code editor button is intentionally left enabled. I'm guessing there must be a reason. But it escapes me.
BTW: I'm using Ext1.1
Alternatively, I suppose the real question is, why does the component resize when the sourceedit button is clicked? Maybe that's the real fix. Come to think of it, in an ideal world, there should be no reason the source edit button *shouldn't* be available, except to fix this bug.