3 * This is a modified version of the ck editor integration from the public
4 * domain source in http://www.sencha.com/forum/showthread.php?79031.
6 * Fixed issues when loading multiple editors in multiple TabPanels, wrong calls
7 * to the superclass methods.
11 Ext.namespace("Ext.ux.form");
13 Ext.ux.form.CKEditor = function(config){
16 this.config.CKConfig = Ext.apply({
19 '!','"','#','$','%','&',"'",'(',')','*','+','-','.','/',
20 '0','1','2','3','4','5','6','7','8','9',':',';',
22 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
23 'P','Q','R','S','T','U','V','W','X','Y','Z',
25 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
26 'q','r','s','t','u','v','w','x','y','z',
28 "€", "‘", "’", "“", "”", "–", "—", "¡", "¢", "£", "¤", "¥", "¦", "§",
29 "¨", "©", "ª", "«", "¬", "®", "¯", "°", "²", "³", "´", "µ", "¶", "·", "¸", "¹",
30 "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É",
31 "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú",
32 "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë",
33 "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü",
34 "ý", "þ", "ÿ", "Œ", "œ", "Ŵ", "Ŷ", "ŵ", "ŷ", "‚", "‛", "„", "…", "™", "►", "•",
35 "→", "⇒", "⇔", "♦", "≈",
36 ["α", ""], ["β", ""], ["∂", ""], "∆", ["ε", ""], ["∑", ""], ["ƒ", ""], ["Γ", ""], ["γ", ""],
37 ["∫", ""], ["∞", ""], ["Λ", ""], ["λ", ""], ["µ", ""], ["μ", ""], ["∇", ""],
38 ["Ω", ""], ["ω", ""], ["√", ""], ["∏", ""], ["π", ""], ["Ψ", ""], ["ψ", ""], ["≤", ""], ["≥", ""], ["≠", ""]
41 }, this.config.CKConfig);
43 Ext.ux.form.CKEditor.superclass.constructor.call(this, this.config);
46 Ext.extend(Ext.ux.form.CKEditor, Ext.form.TextArea, {
47 onRender : function(ct, position){
49 this.defaultAutoCreate = {
51 cls: "ckEditorTextArea",
55 Ext.form.TextArea.superclass.onRender.call(this, ct, position);
57 CKEDITOR.on('instanceReady', this.instanceReady, this);
58 CKEDITOR.replace(this.id, this.config.CKConfig);
61 instanceReady: function(e) {
62 // on definit les listeners sur les editors
63 if ( this.config.CKConfig.listeners )
65 for ( var eventName in this.config.CKConfig.listeners )
67 e.editor.on( eventName, this.config.CKConfig.listeners[ eventName ][0], this.config.CKConfig.listeners[ eventName ][1]);
73 this.setValue("<font></font>");
76 setValue : function(value){
77 Ext.form.TextArea.superclass.setValue.call(this,[value]);
78 var ck = CKEDITOR.instances[this.id];
84 getValue : function(){
85 var ck = CKEDITOR.instances[this.id];
89 return Ext.form.TextArea.superclass.getValue.call(this);
92 isDirty: function () {
93 if (this.disabled || !this.rendered) {
96 return String(this.getValue()) !== String(this.originalValue);
99 getRawValue : function(){
100 var ck = CKEDITOR.instances[this.id];
104 return Ext.form.TextArea.superclass.getRawValue.call(this);
107 destroyInstance: function(){
108 var ck = CKEDITOR.instances[this.id];
114 setContentElement: function(id, content) {
115 var ck = CKEDITOR.instances[this.id];
117 ck.document.getById(id).setHtml(content);
121 getInstance: function() {
122 return CKEDITOR.instances[this.id];
125 resize : function(width, height){
126 Ext.form.TextArea.superclass.setSize.call(this,[width, height]);
127 var ck = CKEDITOR.instances[this.id];
129 ck.resize(width, height);
136 Ext.reg('ckeditor', Ext.ux.form.CKEditor);