View Full Version : adding button to htmleditor

20 May 2010, 10:25 PM
hi, i've searched forum but found nothing to help me exactly.
i'm using extjs 3 and i have an htmleditor.
i'm wondering if there is a way to add a button to htmleditor toolbar easily?
i've added a button with handler function. it does not look well with 'B' image on it. but this is not the main issue.
i want to add 'pre' tag around selected text. like at this editor that i wrote this message.(code block)

var editor = new Ext.form.HtmlEditor({
var new_button = new Ext.Button({
handler: insertPreTag

editor.on('render', function(){
function insertPreTag()
}any help?
thanks in advance.

22 May 2010, 10:13 AM
hi, i solved one of my problems. but not sure if it is the right way. my code is below:

var new_button = new Ext.Button({
handler: kodBloguEkle,
scope: this,
text: '#',
iconCls: 'kodButon',
Ext.getCmp('formDuzenleIcerik').on('render', function(){
Ext.getCmp('formDuzenleIcerik').getToolbar().addButton(new_button );

function kodBloguEkle()
var _editor = Ext.getCmp('formDuzenleIcerik') ;
var secilen = '' ;
secilen = _editor.iframe.contentDocument.getSelection() ;
else if(Ext.isIE || Ext.isOpera)
secilen = _editor.iframe.contentDocument.selection.createRange().text ;
else if (Ext.isWebKit) // not sure but if browser is chrome
secilen = _editor.iframe.contentWindow.getSelection() ;

_editor.insertAtCursor('(CODE)' + secilen + '(/CODE)') ;//brackets
}other problem is the button's style and text? how can i solve this?

17 Aug 2010, 1:36 AM
i also need a solution, for exactly the same problem!