Ticket #7285: 7285_3.patch

File 7285_3.patch, 19.1 KB (added by kaga, 13 years ago)
  • trunk/CKEditor.NET/CKEditorConfig.cs

     
    178178                                if (customName == "ExtraOptions")
    179179                                        foreach (object[] item in (object[])propertyInfo.GetValue(obj, new object[0]))
    180180                                                oc.Append(", ").Append("\"" + item[0].ToString() + "\" : ").Append(item[1].ToString());
     181                                else if (customName == "stylesSet" && ((string[])propertyInfo.GetValue(obj, new object[0])).Length == 1 && !((string[])propertyInfo.GetValue(obj, new object[0]))[0].StartsWith("{"))
     182                                {
     183                                        object staticValueToCompare = staticPropertyInfoDictionary[propertyInfo.Name];
     184                                        if (!campareArray(((string[]) propertyInfo.GetValue(obj, new object[0])), (string[]) staticValueToCompare))
     185                                        {
     186                                                string[] valueToJSON = (string[]) propertyInfo.GetValue(obj, new object[0]);
     187                                                sbJSON.Append("\"" + (string.IsNullOrEmpty(customName) ? propertyInfo.Name : customName) + "\" : ");
     188                                                if ((valueToJSON[0].StartsWith("[") || valueToJSON[0].StartsWith("{")) &&
     189                                                        (valueToJSON[0].EndsWith("]") || valueToJSON[0].EndsWith("}")))
     190                                                        sbJSON.Append(EscapeStringForJavaScript(valueToJSON[0]).TrimStart(new char[] { '\'' }).TrimEnd(new char[] { '\'' }));
     191                                                else
     192                                                        sbJSON.Append("\"" + EscapeStringForJavaScript(valueToJSON[0]).TrimStart(new char[] {'\''}).TrimEnd(new char[] {'\''}) + "\"");
     193                                                sbJSON.Append(", ");
     194                                        }
     195                                        continue;
     196                                }
    181197                                else if (customName == "on" && ((object[])propertyInfo.GetValue(obj, new object[0])).Length > 0)
    182198                                {
    183199                                        object[] objArray = (object[])((object[])propertyInfo.GetValue(obj, new object[0]))[0];
     
    201217                                                        continue;
    202218                                        }
    203219                                        sbJSON.Append("\"" + (string.IsNullOrEmpty(customName) ? propertyInfo.Name : customName) + "\" : ");
     220                                        if (propertyInfo.Name == "toolbar" || propertyInfo.Name == "toolbar_Basic" || propertyInfo.Name == "toolbar_Full")
     221                                        {
     222                                                object toolObj;
     223                                                if (propertyInfo.Name == "toolbar") toolObj = propertyInfo.GetValue(obj, new object[0]);
     224                                                else toolObj = ((object[])propertyInfo.GetValue(obj, new object[0]))[0];
     225                                                if (toolObj.GetType() == typeof(string) && ((string)toolObj).StartsWith("[") && ((string)toolObj).EndsWith("]"))
     226                                                {
     227                                                        isObject = true;
     228                                                        GetFieldOrPropertyValue(ref sbJSON, toolObj, removeEnters, isObject);
     229                                                        sbJSON.Append(", ");
     230                                                        continue;
     231                                                }
     232                                        }
    204233                                        GetFieldOrPropertyValue(ref sbJSON, propertyInfo.GetValue(obj, new object[0]), removeEnters, isObject);
    205234                                        sbJSON.Append(", ");
    206235                                }
     
    446475                /// the contents are to be used.
    447476                /// Default Value: new string[] { "~/contents.css" };
    448477                /// </summary>
    449                 [CKSerializable]
    450478                public string[] contentsCss { get; set; }
     479                [CKSerializable(Name = "contentsCss", IsObject = true)]
     480                private string[] contentsCssSer
     481                {
     482                        get
     483                        {
     484                                List<string> retVal = new List<string>();
     485                                ResolveParameters(contentsCss, retVal, true);
     486                                return retVal.ToArray();
     487                        }
     488                }
    451489
    452490                /// <summary>
    453491                /// The writting direction of the language used to write the editor contents. Allowed values are:
     
    472510                public string contentsLanguage { get; set; }
    473511
    474512                /// <summary>
    475                 /// A comma separated list of plugins that are not related to editor instances. Reserved to plugins that extend the core code only.
    476                 /// There are no ways to override this setting, except by editing the source code of CKEditor (_source/core/config.js).
    477                 /// </summary>
    478                 [CKSerializable]
    479                 public string corePlugins { get; set; }
    480 
    481                 /// <summary>
    482513                /// The style definition to be used to apply the bold style in the text.
    483514                /// Default Value: "{ element : 'strong', overrides : 'b' }"
    484515                /// </summary>
     
    823854                /// For example, "Bigger Font/14px" will be displayed as "Bigger Font" in the list, but will be outputted as "14px".
    824855                /// Default Value: "8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px"
    825856                /// </summary>
    826                 [CKSerializable(IsObject = true)]
     857                [CKSerializable]
    827858                public string fontSize_sizes { get; set; }
    828859
    829860                /// <summary>
     
    9881019                /// List of classes to use for indenting the contents. If it's null, no classes will be used and instead the #indentUnit and #indentOffset properties will be used.
    9891020                /// Default Value: []
    9901021                /// </summary>
    991                 [CKSerializable]
    9921022                public string[] indentClasses { get; set; }
     1023                [CKSerializable(Name = "indentClasses", IsObject = true)]
     1024                private string[] indentClassesSer
     1025                {
     1026                        get
     1027                        {
     1028                                List<string> retVal = new List<string>();
     1029                                ResolveParameters(indentClasses, retVal, true);
     1030                                return retVal.ToArray();
     1031                        }
     1032                }
    9931033
    9941034                /// <summary>
    9951035                /// Size of each indentation step
     
    10941134                /// List of regular expressions to be executed over the input HTML, indicating HTML source code that matched must not present in WYSIWYG mode for editing.
    10951135                /// Default Value: []
    10961136                /// </summary>
    1097                 public string [] protectedSource { get; set; }
    1098 
     1137                public string[] protectedSource { get; set; }
     1138               
    10991139                /// <summary>
    11001140                /// The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them.
    11011141                /// Separate each pair with semicolon (see example). Note: All names are case-sensitive.
     
    14451485                /// Previously this setting was available as config.stylesCombo_stylesSet
    14461486                /// Default Value: ["'default'"]
    14471487                /// </summary>
    1448                 [CKSerializable(IsObject = true)]
    1449                 public string stylesSet { get; set; }
    1450 
     1488                public string[] stylesSet { get; set; }
     1489                [CKSerializable(Name = "stylesSet", IsObject = true)]
     1490                private string[] stylesSetSer
     1491                {
     1492                        get
     1493                        {
     1494                                if (stylesSet != null && stylesSet.Length == 1 && stylesSet[0].Contains("{") && stylesSet[0].Contains("}"))
     1495                                {
     1496                                        stylesSet[0] = stylesSet[0].Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
     1497                                        return stylesSet;
     1498                                }
     1499                                List<string> retVal = new List<string>();
     1500                                ResolveParameters(stylesSet, retVal, true);
     1501                                return retVal.ToArray();
     1502                        }
     1503                }
    14511504                /// <summary>
    14521505                /// The editor tabindex value.
    14531506                /// Default Value: 0
     
    14671520                /// The list of templates definition files to load.
    14681521                /// Default Value: new string[] { "~/plugins/templates/templates/default.js" };
    14691522                /// </summary>
    1470                 [CKSerializable]
    14711523                public string[] templates_files { get; set; }
     1524                [CKSerializable(Name = "templates_files", IsObject = true)]
     1525                private string[] templates_filesSer
     1526                {
     1527                        get
     1528                        {
     1529                                List<string> retVal = new List<string>();
     1530                                ResolveParameters(templates_files, retVal, true);
     1531                                return retVal.ToArray();
     1532                        }
     1533                }
    14721534
    14731535                /// <summary>
    14741536                /// Whether the "Replace actual contents" checkbox is checked by default in the Templates dialog.
     
    16741736                        GlobalConfigObj.contentsCss = new string[] { "~/contents.css" };
    16751737                        GlobalConfigObj.contentsLangDirection = contentsLangDirections.Ui;
    16761738                        GlobalConfigObj.contentsLanguage = string.Empty;
    1677                         GlobalConfigObj.corePlugins = string.Empty;
    16781739                        GlobalConfigObj.coreStyles_bold = @"{ element : 'strong', overrides : 'b' }";
    16791740                        GlobalConfigObj.coreStyles_italic = @"{ element : 'em', overrides : 'i' }";
    16801741                        GlobalConfigObj.coreStyles_strike = @"{ element : 'strike' }";
     
    18331894                        GlobalConfigObj.startupMode = StartupMode.Wysiwyg;
    18341895                        GlobalConfigObj.startupOutlineBlocks = false;
    18351896                        GlobalConfigObj.startupShowBorders = true;
    1836                         GlobalConfigObj.stylesSet = "default";
     1897                        GlobalConfigObj.stylesSet = new string[] { "default" };
    18371898                        GlobalConfigObj.tabIndex = 0;
    18381899                        GlobalConfigObj.tabSpaces = 0;
    18391900                        GlobalConfigObj.templates_files = new string[] { "~/plugins/templates/templates/default.js" };
     
    18881949                        this.colorButton_backStyle = CKEditorConfig.GlobalConfig.colorButton_backStyle;
    18891950                        this.colorButton_colors = CKEditorConfig.GlobalConfig.colorButton_colors;
    18901951                        this.colorButton_foreStyle = CKEditorConfig.GlobalConfig.colorButton_foreStyle;
    1891                         this.contentsCss = ResoleResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);
     1952                        this.contentsCss = ResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);
    18921953                        this.contentsLangDirection = CKEditorConfig.GlobalConfig.contentsLangDirection;
    18931954                        this.contentsLanguage = CKEditorConfig.GlobalConfig.contentsLanguage;
    1894                         this.corePlugins = CKEditorConfig.GlobalConfig.corePlugins;
    18951955                        this.coreStyles_bold = CKEditorConfig.GlobalConfig.coreStyles_bold;
    18961956                        this.coreStyles_italic = CKEditorConfig.GlobalConfig.coreStyles_italic;
    18971957                        this.coreStyles_strike = CKEditorConfig.GlobalConfig.coreStyles_strike;
     
    20032063                        this.stylesSet = CKEditorConfig.GlobalConfig.stylesSet;
    20042064                        this.tabIndex = CKEditorConfig.GlobalConfig.tabIndex;
    20052065                        this.tabSpaces = CKEditorConfig.GlobalConfig.tabSpaces;
    2006                         this.templates_files = ResoleResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);
     2066                        this.templates_files = ResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);
    20072067                        this.templates_replaceContent = CKEditorConfig.GlobalConfig.templates_replaceContent;
    20082068                        this.theme = CKEditorConfig.GlobalConfig.theme;
    20092069                        this.toolbar = CKEditorConfig.GlobalConfig.toolbar;
     
    20202080                        if (CKEditorInstanceEventHandler != null)
    20212081                                this.CKEditorInstanceEventHandler = new List<object>(CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler);
    20222082                }
    2023                 private string[] ResoleResolveUrl(string[] value, string resolvedStr)
     2083                private string[] ResolveUrl(string[] value, string resolvedStr)
    20242084                {
    20252085                        for (int i = 0; i < value.Length; i++)
    20262086                                if (value[i].StartsWith("~") && !value[i].StartsWith(resolvedStr))
    20272087                                        value[i] = resolvedStr + value[i].Replace("~", "");
    20282088                        return value;
    20292089                }
     2090                private void ResolveParameters(string[] parIn, List<string> retVal, bool addAp)
     2091                {
     2092                        foreach (string item in parIn)
     2093                        {
     2094                                if (item.StartsWith("[") || item.EndsWith("]"))
     2095                                        ResolveParameters(item.Trim().Replace("[", string.Empty).Replace("]", string.Empty).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), retVal, addAp);
     2096                                else if (addAp && !item.StartsWith("'") && !item.EndsWith("'"))
     2097                                        retVal.Add("'" + item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) + "'");
     2098                                else
     2099                                        retVal.Add(item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
     2100                        }
     2101                }
     2102                private string ResolveParameters(string parIn, bool addAp)
     2103                {
     2104                        if (parIn.StartsWith("[") && parIn.EndsWith("]"))
     2105                                return parIn;
     2106                        else if (addAp && !parIn.StartsWith("'") && !parIn.EndsWith("'"))
     2107                                return "'" + parIn + "'";
     2108                        else
     2109                                return parIn;
     2110                }
    20302111                #endregion
    20312112        }
    20322113}
     2114 No newline at end of file
  • trunk/CKEditor.NET/CKEditorControl.cs

     
    149149
    150150                [Category("CKEditor Other Settings")]
    151151                [Description("The editor tabindex value.")]
    152                 [DefaultValue(typeof(short),"0")]
     152                [DefaultValue(typeof(short), "0")]
    153153                public override short TabIndex { get { return (short)config.tabIndex; } set { config.tabIndex = value; } }
    154154
    155155                #region Encaspulate config
     
    163163                [Description("The minimum height to which the editor can reach using AutoGrow.")]
    164164                [DefaultValue(200)]
    165165                public int AutoGrowMinHeight { get { return config.autoGrow_minHeight; } set { config.autoGrow_minHeight = value; } }
    166                
     166
    167167                [Category("CKEditor Other Settings")]
    168168                [Description("Whether the replaced element (usually a textarea) is to be updated automatically when posting the form containing the editor.")]
    169169                [DefaultValue(true)]
     
    207207                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
    208208                                return retVal;
    209209                        }
    210                         set { config.contentsCss = value.Split(new char[] { ',' }); }
     210                        set { config.contentsCss = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); }
    211211                }
    212212
    213                 [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 writing direction of the language used to write the editor contents. Allowed values are:
    214215'ui' - which indicate content direction will be the same with the user interface language direction;
    215216'ltr' - for Left-To-Right language (like English);
    216217'rtl' - for Right-To-Left languages (like Arabic).")]
     
    222223                [DefaultValue("")]
    223224                public string ContentsLanguage { get { return config.contentsLanguage; } set { config.contentsLanguage = value; } }
    224225
    225                 [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.
    226 There are no ways to override this setting, except by editing the source code of CKEditor (_source/core/config.js).")]
    227                 [DefaultValue("")]
    228                 public string CorePlugins { get { return config.corePlugins; } set { config.corePlugins = value; } }
    229 
    230226                [Category("CKEditor Basic Settings")]
    231227                [Description(@"The URL path for the custom configuration file to be loaded. If not overloaded with inline configurations, it defaults
    232228to the ""config.js"" file present in the root of the CKEditor installation directory.
     
    459455                [Category("CKEditor Other Settings")]
    460456                [Description("Whether escape HTML when editor update original input element.")]
    461457                [DefaultValue(true)]
    462                 public bool HtmlEncodeOutput {get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } }
     458                public bool HtmlEncodeOutput { get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } }
    463459
    464460                [Category("CKEditor Other Settings")]
    465461                [Description(@"Whether the editor must output an empty value ("""") if it's contents is made by an empty paragraph only.")]
     
    582578                public bool ScaytAutoStartup { get { return config.scayt_autoStartup; } set { config.scayt_autoStartup = value; } }
    583579
    584580                [Category("CKEditor Other Settings")]
    585                 [DefaultValue("ID of bottom cntrol's shared")]
     581                [Description("ID of bottom cntrol's shared")]
     582                [DefaultValue("")]
    586583                public string SharedSpacesBottom { get { return config.sharedSpacesBottom; } set { config.sharedSpacesBottom = value; } }
    587584
    588585                [Category("CKEditor Other Settings")]
    589                 [DefaultValue("ID of top cntrol's shared")]
     586                [Description("ID of top cntrol's shared")]
     587                [DefaultValue("")]
    590588                public string SharedSpacesTop { get { return config.sharedSpacesTop; } set { config.sharedSpacesTop = value; } }
    591589
    592590                [Category("CKEditor Other Settings")]
     
    618616                [DefaultValue(true)]
    619617                public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } }
    620618
     619                [PersistenceMode(PersistenceMode.Attribute)]
    621620                [Category("CKEditor Other Settings")]
    622621                [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.
    623622The styles may be defined in the page containing the editor, or can be loaded on demand from an external file. In the second case,
     
    625624Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file.
    626625Previously this setting was available as config.stylesCombo_stylesSet")]
    627626                [DefaultValue("default")]
    628                 public string StylesSet { get { return config.stylesSet; } set { config.stylesSet = value; } }
     627                [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
     628                public string StylesSet
     629                {
     630                        get
     631                        {
     632                                string retVal = string.Empty;
     633                                foreach (string item in config.stylesSet) retVal += item + ",";
     634                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
     635                                return retVal;
     636                        }
     637                        set
     638                        {
     639                                if (value.Contains("{") && value.Contains("}"))
     640                                        config.stylesSet = new string[] { value };
     641                                else
     642                                        config.stylesSet = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
     643                        }
     644                }
    629645
    630646                [Category("CKEditor Other Settings")]
    631647                [Description(@"Intructs the editor to add a number of spaces (&nbsp;) to the text when hitting the TAB key.
     
    647663                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
    648664                                return retVal;
    649665                        }
    650                         set { config.templates_files = value.Split(new char[] { ',' }); }
     666                        set { config.templates_files = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); }
    651667                }
    652668
    653669                [Category("CKEditor Other Settings")]
     
    658674                [PersistenceMode(PersistenceMode.Attribute)]
    659675                [Category("CKEditor Basic Settings")]
    660676                [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.")]
    661                 [DefaultValue( "Full")]
     677                [DefaultValue("Full")]
    662678                [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
    663679                public string Toolbar
    664680                {
     
    693709                        }
    694710                        set
    695711                        {
    696                                 string[] valueTab = value.Split(new string[] { "\r\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    697                                 if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic"))
     712                                value = value.Trim();
     713                                if (value.StartsWith("[") && value.EndsWith("]"))
    698714                                {
     715                                        config.toolbar = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
     716                                        return;
     717                                }
     718                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
     719                                if (valueTab.Length == 1)
     720                                {
    699721                                        config.toolbar = valueTab[0];
    700722                                        return;
    701723                                }
     
    756778                        }
    757779                        set
    758780                        {
     781                                value = value.Trim();
     782                                if (value.StartsWith("[") && value.EndsWith("]"))
     783                                {
     784                                        config.toolbar_Basic = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     785                                        return;
     786                                }
    759787                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    760788                                object[] retVal = new object[valueTab.Length];
    761789                                try
     
    825853                        }
    826854                        set
    827855                        {
     856                                value = value.Trim();
     857                                if (value.StartsWith("[") && value.EndsWith("]"))
     858                                {
     859                                        config.toolbar_Full = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     860                                        return;
     861                                }
    828862                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    829863                                object[] retVal = new object[valueTab.Length];
    830864                                try
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy