Ticket #7283: 7283.patch

File 7283.patch, 14.6 KB (added by kaga, 13 years ago)
  • trunk/_dev/msajax.js

     
    2828                        oldPageLoad = window.pageLoad;
    2929
    3030                var fixValues = function () {
    31                         for (i = ids.length; i--;) {
    32                                 var e = document.getElementById(ids[i]);
    33                                 e.value = e.value.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    34                         }
     31                        if (typeof CKEDITOR == 'undefined'){
     32                                for (i = ids.length; i--;) {
     33                                        var e = document.getElementById(ids[i]);
     34                                        e.value = e.value.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
     35                                }
     36                        }
    3537                };
    3638
    3739                window.pageLoad = function(sender, args) {
  • trunk/CKEditor.NET/CKEditorControl.cs

     
    2121        [ToolboxData("<{0}:CKEditorControl runat=server></{0}:CKEditorControl>")]
    2222        [ParseChildren(false)]
    2323        [Designer("CKEditor.NET.CKEditorControlDesigner")]
    24         public class CKEditorControl : TextBox
     24        public class CKEditorControl : TextBox, IPostBackDataHandler
    2525        {
    2626                #region Changed TextBox Property
    2727
     
    3232                {
    3333                        get
    3434                        {
    35                                 if (!string.IsNullOrEmpty(base.Text))
    36                                         base.Text = base.Text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
    3735                                return base.Text;
    3836                        }
    3937                        set
    4038                        {
    41                                 if (!string.IsNullOrEmpty(value))
    42                                         value = value.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
    4339                                base.Text = value;
    4440                        }
    4541                }
     
    153149
    154150                [Category("CKEditor Other Settings")]
    155151                [Description("The editor tabindex value.")]
    156                 [DefaultValue(typeof(short),"0")]
     152                [DefaultValue(typeof(short), "0")]
    157153                public override short TabIndex { get { return (short)config.tabIndex; } set { config.tabIndex = value; } }
    158154
    159155                #region Encaspulate config
     
    167163                [Description("The minimum height to which the editor can reach using AutoGrow.")]
    168164                [DefaultValue(200)]
    169165                public int AutoGrowMinHeight { get { return config.autoGrow_minHeight; } set { config.autoGrow_minHeight = value; } }
    170                
     166
    171167                [Category("CKEditor Other Settings")]
    172168                [Description("Whether the replaced element (usually a textarea) is to be updated automatically when posting the form containing the editor.")]
    173169                [DefaultValue(true)]
     
    211207                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
    212208                                return retVal;
    213209                        }
    214                         set { config.contentsCss = value.Split(new char[] { ',' }); }
     210                        set { config.contentsCss = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); }
    215211                }
    216212
    217                 [Category("CKEditor Other Settings")][Description(@"The writting direction of the language used to write the editor contents. Allowed values are:
     213                [Category("CKEditor Other Settings")]
     214                [Description(@"The writting direction of the language used to write the editor contents. Allowed values are:
    218215'ui' - which indicate content direction will be the same with the user interface language direction;
    219216'ltr' - for Left-To-Right language (like English);
    220217'rtl' - for Right-To-Left languages (like Arabic).")]
     
    226223                [DefaultValue("")]
    227224                public string ContentsLanguage { get { return config.contentsLanguage; } set { config.contentsLanguage = value; } }
    228225
    229                 [Category("CKEditor Other Settings")][Description(@"A comma separated list of plugins that are not related to editor instances. Reserved to plugins that extend the core code only.
    230 There are no ways to override this setting, except by editing the source code of CKEditor (_source/core/config.js).")]
    231                 [DefaultValue("")]
    232                 public string CorePlugins { get { return config.corePlugins; } set { config.corePlugins = value; } }
    233 
    234226                [Category("CKEditor Basic Settings")]
    235227                [Description(@"The URL path for the custom configuration file to be loaded. If not overloaded with inline configurations, it defaults
    236228to the ""config.js"" file present in the root of the CKEditor installation directory.
     
    463455                [Category("CKEditor Other Settings")]
    464456                [Description("Whether escape HTML when editor update original input element.")]
    465457                [DefaultValue(true)]
    466                 public bool HtmlEncodeOutput {get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } }
     458                public bool HtmlEncodeOutput { get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } }
    467459
    468460                [Category("CKEditor Other Settings")]
    469461                [Description(@"Whether the editor must output an empty value ("""") if it's contents is made by an empty paragraph only.")]
     
    632624                [DefaultValue(true)]
    633625                public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } }
    634626
     627                [PersistenceMode(PersistenceMode.Attribute)]
    635628                [Category("CKEditor Other Settings")]
    636629                [Description(@"The ""styles definition set"" to use in the editor. They will be used in the styles combo and the Style selector of the div container.
    637630The styles may be defined in the page containing the editor, or can be loaded on demand from an external file. In the second case,
     
    639632Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file.
    640633Previously this setting was available as config.stylesCombo_stylesSet")]
    641634                [DefaultValue("default")]
    642                 public string StylesSet { get { return config.stylesSet; } set { config.stylesSet = value; } }
     635                [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
     636                public string StylesSet
     637                {
     638                        get
     639                        {
     640                                string retVal = string.Empty;
     641                                foreach (string item in config.stylesSet) retVal += item + ",";
     642                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
     643                                return retVal;
     644                        }
     645                        set
     646                        {
     647                                if (value.Contains("{") && value.Contains("}"))
     648                                        config.stylesSet = new string[] { value };
     649                                else
     650                                        config.stylesSet = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     651                        }
     652                }
    643653
    644654                [Category("CKEditor Other Settings")]
    645655                [Description(@"Intructs the editor to add a number of spaces (&nbsp;) to the text when hitting the TAB key.
     
    661671                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
    662672                                return retVal;
    663673                        }
    664                         set { config.templates_files = value.Split(new char[] { ',' }); }
     674                        set { config.templates_files = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); }
    665675                }
    666676
    667677                [Category("CKEditor Other Settings")]
     
    672682                [PersistenceMode(PersistenceMode.Attribute)]
    673683                [Category("CKEditor Basic Settings")]
    674684                [Description("The toolbox (alias toolbar) definition. It is a toolbar name or an array of toolbars (strips), each one being also an array, containing a list of UI items.")]
    675                 [DefaultValue( "Full")]
     685                [DefaultValue("Full")]
    676686                [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
    677687                public string Toolbar
    678688                {
     
    707717                        }
    708718                        set
    709719                        {
    710                                 string[] valueTab = value.Split(new string[] { "\r\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
     720                                value = value.Trim();
     721                                if (value.StartsWith("[") && value.EndsWith("]"))
     722                                {
     723                                        config.toolbar = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
     724                                        return;
     725                                }
     726                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    711727                                if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic"))
    712728                                {
    713729                                        config.toolbar = valueTab[0];
     
    770786                        }
    771787                        set
    772788                        {
     789                                value = value.Trim();
     790                                if (value.StartsWith("[") && value.EndsWith("]"))
     791                                {
     792                                        config.toolbar_Basic = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     793                                        return;
     794                                }
    773795                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    774796                                object[] retVal = new object[valueTab.Length];
    775797                                try
     
    839861                        }
    840862                        set
    841863                        {
     864                                value = value.Trim();
     865                                if (value.StartsWith("[") && value.EndsWith("]"))
     866                                {
     867                                        config.toolbar_Full = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     868                                        return;
     869                                }
    842870                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    843871                                object[] retVal = new object[valueTab.Length];
    844872                                try
     
    9991027                {
    10001028                        this.RegisterStartupScript(this.GetType(), "CKEDITOR_BASEPATH", string.Format("window.CKEDITOR_BASEPATH = '{0}/';\n", (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath)), true);
    10011029                        this.RegisterStartupScript(this.GetType(), "ckeditor", "<script src=\"" + (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.CKEditorJSFile) : this.CKEditorJSFile) + timestamp + "\" type=\"text/javascript\"></script>", false);
    1002                         if (HasMsAjax)
    1003                         {
    1004                                 string scriptInit = string.Empty;
     1030                        string scriptInit = string.Empty;
    10051031
    1006                                 // Sys.Application.add_load does not work on browsers != IE
    1007                                 // http://msdn.microsoft.com/en-us/library/bb386417.aspx
    1008                                 // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN).
    1009                                 scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'&lt;').replace(/>/g,'&gt;');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/&lt;/g,'<').replace(/&gt;/g,'>');}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})();
     1032                        // Sys.Application.add_load does not work on browsers != IE
     1033                        // http://msdn.microsoft.com/en-us/library/bb386417.aspx
     1034                        // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN).
     1035                        scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'&lt;').replace(/>/g,'&gt;');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){if(typeof CKEDITOR == 'undefined'){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/&lt;/g,'<').replace(/&gt;/g,'>');}}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})();
    10101036";
    1011 
    1012                                 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true);
    1013                                 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}');
     1037                        this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true);
     1038                        this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}');
    10141039", this.ClientID), true);
    1015                         }
    10161040                        string script = string.Empty;
    10171041                        if (this.config.CKEditorEventHandler != null)
    10181042                                foreach (object[] item in this.config.CKEditorEventHandler)
     
    10201044                                        script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.on('{0}',{1});
    10211045", item[0], item[1]);
    10221046                                }
    1023                         script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1});
     1047                        if (this.config.protectedSource != null && this.config.protectedSource.Length > 0)
     1048                        {
     1049                                string proSour = string.Empty;
     1050                                foreach (string item in this.config.protectedSource)
     1051                                        proSour += @"
     1052ckeditor.config.protectedSource.push( " + item + " );";
     1053                                script += string.Format(@"if(typeof CKEDITOR != 'undefined') {3}
     1054var ckeditor = CKEDITOR.replace('{0}',{1}); {2}
     1055{4}", this.ClientID, prepareJSON(), proSour, "{", "}");
     1056                        }
     1057                        else
     1058                                script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1});
    10241059", this.ClientID, prepareJSON());
    10251060
    1026                         if (HasMsAjax)
    1027                         {
    1028                                 bool isInUpdatePanel = false;
    1029                                 Control con = this.Parent;
    1030                                 if (updatePanel != null)
    1031                                         while (con != null)
     1061                        bool isInUpdatePanel = false;
     1062                        Control con = this.Parent;
     1063                        if (updatePanel != null)
     1064                                while (con != null)
     1065                                {
     1066                                        if (con.GetType() == updatePanel)
    10321067                                        {
    1033                                                 if (con.GetType() == updatePanel)
    1034                                                 {
    1035                                                         isInUpdatePanel = true;
    1036                                                         break;
    1037                                                 }
    1038                                                 con = con.Parent;
     1068                                                isInUpdatePanel = true;
     1069                                                break;
    10391070                                        }
    1040                                 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0));
    1041                         }
     1071                                        con = con.Parent;
     1072                                }
     1073                        this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0));
    10421074                        this.RegisterStartupScript(this.GetType(), "aspintegratorInitial_" + this.ClientID, script, true);
    10431075                }
    10441076
     
    10521084                }
    10531085
    10541086                #endregion
     1087
     1088                #region IPostBackDataHandler
     1089
     1090                bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
     1091                {
     1092                        if (this.config.htmlEncodeOutput)
     1093                        {
     1094                                string postedValue = postCollection[postDataKey];
     1095                                postedValue = postedValue.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
     1096                                if (this.Text != postedValue)
     1097                                {
     1098                                        this.Text = postedValue;
     1099                                        return true;
     1100                                }
     1101                        }
     1102                        return false;
     1103                }
     1104
     1105                void IPostBackDataHandler.RaisePostDataChangedEvent() { }
     1106
     1107                #endregion
    10551108        }
    10561109
    10571110        public class CKEditorControlDesigner : System.Web.UI.Design.ControlDesigner
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy