--- /dev/null
+
+/*
+ * This is a modified version of the ck editor integration from the public
+ * domain source in http://www.sencha.com/forum/showthread.php?79031.
+ *
+ * Fixed issues when loading multiple editors in multiple TabPanels, wrong calls
+ * to the superclass methods.
+ */
+
+
+Ext.namespace("Ext.ux.form");
+
+Ext.ux.form.CKEditor = function(config){
+ this.config = config;
+
+ this.config.CKConfig = Ext.apply({
+ uiColor: '#DFE8F6',
+ specialChars:[
+ '!','"','#','$','%','&',"'",'(',')','*','+','-','.','/',
+ '0','1','2','3','4','5','6','7','8','9',':',';',
+ '<','=','>','?','@',
+ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
+ 'P','Q','R','S','T','U','V','W','X','Y','Z',
+ '[',']','^','_','`',
+ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
+ 'q','r','s','t','u','v','w','x','y','z',
+ '{','|','}','~',
+ "€", "‘", "’", "“", "”", "–", "—", "¡", "¢", "£", "¤", "¥", "¦", "§",
+ "¨", "©", "ª", "«", "¬", "®", "¯", "°", "²", "³", "´", "µ", "¶", "·", "¸", "¹",
+ "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É",
+ "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú",
+ "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë",
+ "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü",
+ "ý", "þ", "ÿ", "Œ", "œ", "Ŵ", "Ŷ", "ŵ", "ŷ", "‚", "‛", "„", "…", "™", "►", "•",
+ "→", "⇒", "⇔", "♦", "≈",
+ ["α", ""], ["β", ""], ["∂", ""], "∆", ["ε", ""], ["∑", ""], ["ƒ", ""], ["Γ", ""], ["γ", ""],
+ ["∫", ""], ["∞", ""], ["Λ", ""], ["λ", ""], ["µ", ""], ["μ", ""], ["∇", ""],
+ ["Ω", ""], ["ω", ""], ["√", ""], ["∏", ""], ["π", ""], ["Ψ", ""], ["ψ", ""], ["≤", ""], ["≥", ""], ["≠", ""]
+ ]
+
+ }, this.config.CKConfig);
+
+ Ext.ux.form.CKEditor.superclass.constructor.call(this, this.config);
+};
+
+Ext.extend(Ext.ux.form.CKEditor, Ext.form.TextArea, {
+ onRender : function(ct, position){
+ if(!this.el){
+ this.defaultAutoCreate = {
+ tag: "textarea",
+ cls: "ckEditorTextArea",
+ autocomplete: "off"
+ };
+ }
+ Ext.form.TextArea.superclass.onRender.call(this, ct, position);
+
+ CKEDITOR.on('instanceReady', this.instanceReady, this);
+ CKEDITOR.replace(this.id, this.config.CKConfig);
+ },
+
+ instanceReady: function(e) {
+ // on definit les listeners sur les editors
+ if ( this.config.CKConfig.listeners )
+ {
+ for ( var eventName in this.config.CKConfig.listeners )
+ {
+ e.editor.on( eventName, this.config.CKConfig.listeners[ eventName ][0], this.config.CKConfig.listeners[ eventName ][1]);
+ }
+ }
+ },
+
+ reset: function() {
+ this.setValue("<font></font>");
+ },
+
+ setValue : function(value){
+ Ext.form.TextArea.superclass.setValue.call(this,[value]);
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ ck.setData( value );
+ }
+ },
+
+ getValue : function(){
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ ck.updateElement();
+ }
+ return Ext.form.TextArea.superclass.getValue.call(this);
+ },
+
+ isDirty: function () {
+ if (this.disabled || !this.rendered) {
+ return false;
+ }
+ return String(this.getValue()) !== String(this.originalValue);
+ },
+
+ getRawValue : function(){
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ ck.updateElement();
+ }
+ return Ext.form.TextArea.superclass.getRawValue.call(this);
+ },
+
+ destroyInstance: function(){
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ delete ck;
+ }
+ },
+
+ setContentElement: function(id, content) {
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ ck.document.getById(id).setHtml(content);
+ }
+ },
+
+ getInstance: function() {
+ return CKEDITOR.instances[this.id];
+ },
+
+ resize : function(width, height){
+ Ext.form.TextArea.superclass.setSize.call(this,[width, height]);
+ var ck = CKEDITOR.instances[this.id];
+ if (ck){
+ ck.resize(width, height);
+ }
+ }
+
+
+});
+
+Ext.reg('ckeditor', Ext.ux.form.CKEditor);
\ No newline at end of file