// initialize quicktips Ext.QuickTips.init(); Ext.namespace('Perlmonks'); Perlmonks.HtmlEditor = Ext.extend( Ext.form.HtmlEditor, { enableAlignments: false, enableLinks: false, enablePMLinks: false, createToolbar : function(editor){ Perlmonks.HtmlEditor.superclass.createToolbar.call(this, editor); this.tb.items.item('backcolor').hide(); }, setValue : function(v){ v = v.replace(/\n/g, String.fromCharCode(222)); while ( v.match(/(.+?)<\/code>/i) ) { v = v.replace(/(.+?)<\/code>/ig, escapeCode(RegExp.$1)); } while ( v.match(/(.+?)<\/c>/i) ) { v = v.replace(/(.+?)<\/c>/ig, escapeCode(RegExp.$1)); } v = v.replace(new RegExp(String.fromCharCode(222), 'g'), "\n"); Perlmonks.HtmlEditor.superclass.setValue.call(this, v); }, getValue : function(){ var v = Perlmonks.HtmlEditor.superclass.getValue.call(this); v = v.replace(/\n/g, String.fromCharCode(222)); while ( v.match(/
(.+?)<\/pre>/) )
		{
			v = v.replace(/
(.+?)<\/pre>/g, deEscapeCode(RegExp.$1));
		}

		v = v.replace(new RegExp(String.fromCharCode(222), 'g'), "\n");

		return v;
	},
	
	getDocMarkup : function(){
        return '';
    }
	

});

function deEscapeCode (txt)
{
	txt = txt.replace(/</g, '<'); txt = txt.replace(/>/g, '>');
	txt = txt.replace(/
/g, "\n"); return String.format("{0}", txt); } function escapeCode (txt) { txt = txt.replace(//g, '>'); return String.format('
{0}
', txt); } function find_my_ta () { var a = document.getElementsByTagName('textarea'); for (var i=0; i## // find the textare of the current page and add a a link to show the html editor dialog var ta = find_my_ta(); Ext.DomHelper.insertAfter(ta, { tag: 'p', html: 'html edit' }); // the editor dialog var ed = new Ext.Window({ layout:'fit', width:500, height:300, closeAction:'hide', maximizable: true, plain: true, items: new Perlmonks.HtmlEditor({ id: 'html_editor' }), buttons: new Array ( { text:'Ok', handler: function(){ ta.value = Ext.getCmp('html_editor').getValue(); ed.hide(); } }, { text: 'Cancel', handler: function(){ ed.hide(); } } ) }); ed.on('show', function(){ Ext.getCmp('html_editor').setValue(ta.value); }); Ext.get('show_html_edit').dom.onclick = function (event) { try { ed.show(); } catch (e) { alert(e); } return false; };