-
10 Jun 2009 1:15 PM #1
[TENT][3.0.0] Ext.HtmlEditor.insertAtCursor and Chrome
[TENT][3.0.0] Ext.HtmlEditor.insertAtCursor and Chrome
Hello,
No implementation in the function for Chrome:
Cheers,Code:/** * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated * to insert text. * @param {String} text */ insertAtCursor : function(text){ if(!this.activated){ return; } if(Ext.isIE){ this.win.focus(); var r = this.doc.selection.createRange(); if(r){ r.collapse(true); r.pasteHTML(text); this.syncValue(); this.deferFocus(); } }else if(Ext.isGecko || Ext.isOpera || Ext.isChrome){ this.win.focus(); this.execCmd('InsertHTML', text); this.deferFocus(); }else if(Ext.isWebKit){ this.execCmd('InsertText', text); this.deferFocus(); } },
Timothy
-
10 Jun 2009 1:30 PM #2
Thanks for your report.
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
10 Jun 2009 7:32 PM #3
the OP is incorrect. Chrome is WebKit.
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
10 Jun 2009 7:33 PM #4
@OP: Is this actually causing an issue, or is this just from looking at the code?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
11 Jun 2009 5:53 PM #5
-
11 Jun 2009 8:30 PM #6
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
12 Jun 2009 3:29 AM #7
-
12 Jun 2009 7:38 PM #8
If you are experiencing an issue, please post a test case of some working code which illustrates the problem. Format for a test case:
http://extjs.com/learn/Ext_Forum_Hel...rking_showcaseMJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
16 Jul 2009 7:40 AM #9
Wish the OP had followed up on this, but I have run into this issue (err, or something similar?) as well, so Ill hijack this bug.
Problem: The InsertText Midas command in Chrome htmlencodes the value before inserting it, which will of course mess up any html elements you try to insert via the insertAtCursor handler.
Solution: Chrome can handle the InsertHTML Midas command, so why not use that instead which will take care of both cases when you want to insert just text or html elements and text.
This override appears to fix the problem:
Tested in these browsers (All on Vista):Code:Ext.override(Ext.form.HtmlEditor, { insertAtCursor : function(text){ if(!this.activated){ return; } if(Ext.isIE){ this.win.focus(); var r = this.doc.selection.createRange(); if(r){ r.collapse(true); r.pasteHTML(text); this.syncValue(); this.deferFocus(); } }else if(Ext.isGecko || Ext.isOpera || Ext.isWebKit){ this.win.focus(); this.execCmd('InsertHTML', text); this.deferFocus(); } } });- FireFox 3.5 (30729)
- Internet Explorer 8 (18783)
- Chrome 2 (172.33)
- Safari 4.0 (530.17)
- Opera 9.64 (10487)
Here is a test case which can replace the examples/form/anchoring.js files contents.
Code:Ext.override(Ext.form.HtmlEditor, { insertAtCursor : function(text){ if(!this.activated){ return; } if(Ext.isIE){ this.win.focus(); var r = this.doc.selection.createRange(); if(r){ r.collapse(true); r.pasteHTML(text); this.syncValue(); this.deferFocus(); } }else if(Ext.isGecko || Ext.isOpera || Ext.isWebKit){ this.win.focus(); this.execCmd('InsertHTML', text); this.deferFocus(); } } }); 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', id: 'myeditor', anchor: '100% -53', // anchor width by percentage and height by raw adjustment listeners: { afterrender: function(t){ t.getToolbar().addButton({ text: 'test', handler: function(t){ Ext.getCmp('myeditor').insertAtCursor('<b>Test</b>'); } }); } } }] }); var window = new Ext.Window({ title: 'Resize Me', width: 600, height:300, minWidth: 300, minHeight: 200, layout: 'fit', plain:true, bodyStyle:'padding:5px;', buttonAlign:'center', items: form, buttons: [{ text: 'Send' },{ text: 'Cancel' }] }); window.show(); });-Shea
My Blog:VinylFox | Twitter:@VinylFox | JavaScript Magazine:JSMag | Curator of the Baltimore/DC JavaScript Meetup | Author: Learning ExtJS 3.x Book
ExtJS Extensions & Plugins: GMapPanel UX | HtmlEditor Buttons Plugin | Selection Enabler Plugin | Grid DataDrop Plugin | Additional Ext.Fx
Sencha Touch Plugins: Swipe Tabs | List Pull Refresh | Accelerometer Tabs
-
16 Jul 2009 9:21 AM #10
Fixed in SVN, thanks.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote


