Ticket #7285: 7285_2.patch

File 7285_2.patch, 18.8 KB (added by Wiktor Walc, 13 years ago)
  • 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                                                sbJSON.Append("\"" + EscapeStringForJavaScript(valueToJSON[0]).TrimStart(new char[] { '\'' }).TrimEnd(new char[] { '\'' }) + "\"");
     189                                                sbJSON.Append(", ");
     190                                        }
     191                                        continue;
     192                                }
    181193                                else if (customName == "on" && ((object[])propertyInfo.GetValue(obj, new object[0])).Length > 0)
    182194                                {
    183195                                        object[] objArray = (object[])((object[])propertyInfo.GetValue(obj, new object[0]))[0];
     
    201213                                                        continue;
    202214                                        }
    203215                                        sbJSON.Append("\"" + (string.IsNullOrEmpty(customName) ? propertyInfo.Name : customName) + "\" : ");
     216                                        if (propertyInfo.Name == "toolbar" || propertyInfo.Name == "toolbar_Basic" || propertyInfo.Name == "toolbar_Full")
     217                                        {
     218                                                object toolObj;
     219                                                if (propertyInfo.Name == "toolbar") toolObj = propertyInfo.GetValue(obj, new object[0]);
     220                                                else toolObj = ((object[])propertyInfo.GetValue(obj, new object[0]))[0];
     221                                                if (toolObj.GetType() == typeof(string) && ((string)toolObj).StartsWith("[") && ((string)toolObj).EndsWith("]"))
     222                                                {
     223                                                        isObject = true;
     224                                                        GetFieldOrPropertyValue(ref sbJSON, toolObj, removeEnters, isObject);
     225                                                        sbJSON.Append(", ");
     226                                                        continue;
     227                                                }
     228                                        }
    204229                                        GetFieldOrPropertyValue(ref sbJSON, propertyInfo.GetValue(obj, new object[0]), removeEnters, isObject);
    205230                                        sbJSON.Append(", ");
    206231                                }
     
    446471                /// the contents are to be used.
    447472                /// Default Value: new string[] { "~/contents.css" };
    448473                /// </summary>
    449                 [CKSerializable]
    450474                public string[] contentsCss { get; set; }
     475                [CKSerializable(Name = "contentsCss", IsObject = true)]
     476                private string[] contentsCssSer
     477                {
     478                        get
     479                        {
     480                                List<string> retVal = new List<string>();
     481                                ResolveParameters(contentsCss, retVal, true);
     482                                return retVal.ToArray();
     483                        }
     484                }
    451485
    452486                /// <summary>
    453487                /// The writting direction of the language used to write the editor contents. Allowed values are:
     
    472506                public string contentsLanguage { get; set; }
    473507
    474508                /// <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>
    482509                /// The style definition to be used to apply the bold style in the text.
    483510                /// Default Value: "{ element : 'strong', overrides : 'b' }"
    484511                /// </summary>
     
    823850                /// For example, "Bigger Font/14px" will be displayed as "Bigger Font" in the list, but will be outputted as "14px".
    824851                /// 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"
    825852                /// </summary>
    826                 [CKSerializable(IsObject = true)]
     853                [CKSerializable]
    827854                public string fontSize_sizes { get; set; }
    828855
    829856                /// <summary>
     
    9881015                /// 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.
    9891016                /// Default Value: []
    9901017                /// </summary>
    991                 [CKSerializable]
    9921018                public string[] indentClasses { get; set; }
     1019                [CKSerializable(Name = "indentClasses", IsObject = true)]
     1020                private string[] indentClassesSer
     1021                {
     1022                        get
     1023                        {
     1024                                List<string> retVal = new List<string>();
     1025                                ResolveParameters(indentClasses, retVal, true);
     1026                                return retVal.ToArray();
     1027                        }
     1028                }
    9931029
    9941030                /// <summary>
    9951031                /// Size of each indentation step
     
    10941130                /// 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.
    10951131                /// Default Value: []
    10961132                /// </summary>
    1097                 [CKSerializable(IsObject = true)]
    1098                 public object[] protectedSource { get; set; }
     1133                public string[] protectedSource { get; set; }
    10991134
    11001135                /// <summary>
    11011136                /// The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them.
     
    14461481                /// Previously this setting was available as config.stylesCombo_stylesSet
    14471482                /// Default Value: ["'default'"]
    14481483                /// </summary>
    1449                 [CKSerializable(IsObject = true)]
    1450                 public string stylesSet { get; set; }
    1451 
     1484                public string[] stylesSet { get; set; }
     1485                [CKSerializable(Name = "stylesSet", IsObject = true)]
     1486                private string[] stylesSetSer
     1487                {
     1488                        get
     1489                        {
     1490                                if (stylesSet != null && stylesSet.Length == 1 && stylesSet[0].Contains("{") && stylesSet[0].Contains("}"))
     1491                                {
     1492                                        stylesSet[0] = stylesSet[0].Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
     1493                                        return stylesSet;
     1494                                }
     1495                                List<string> retVal = new List<string>();
     1496                                ResolveParameters(stylesSet, retVal, true);
     1497                                return retVal.ToArray();
     1498                        }
     1499                }
    14521500                /// <summary>
    14531501                /// The editor tabindex value.
    14541502                /// Default Value: 0
     
    14681516                /// The list of templates definition files to load.
    14691517                /// Default Value: new string[] { "~/plugins/templates/templates/default.js" };
    14701518                /// </summary>
    1471                 [CKSerializable]
    14721519                public string[] templates_files { get; set; }
     1520                [CKSerializable(Name = "templates_files", IsObject = true)]
     1521                private string[] templates_filesSer
     1522                {
     1523                        get
     1524                        {
     1525                                List<string> retVal = new List<string>();
     1526                                ResolveParameters(templates_files, retVal, true);
     1527                                return retVal.ToArray();
     1528                        }
     1529                }
    14731530
    14741531                /// <summary>
    14751532                /// Whether the "Replace actual contents" checkbox is checked by default in the Templates dialog.
     
    16751732                        GlobalConfigObj.contentsCss = new string[] { "~/contents.css" };
    16761733                        GlobalConfigObj.contentsLangDirection = contentsLangDirections.Ui;
    16771734                        GlobalConfigObj.contentsLanguage = string.Empty;
    1678                         GlobalConfigObj.corePlugins = string.Empty;
    16791735                        GlobalConfigObj.coreStyles_bold = @"{ element : 'strong', overrides : 'b' }";
    16801736                        GlobalConfigObj.coreStyles_italic = @"{ element : 'em', overrides : 'i' }";
    16811737                        GlobalConfigObj.coreStyles_strike = @"{ element : 'strike' }";
     
    17771833                        GlobalConfigObj.pasteFromWordRemoveStyles = false;
    17781834                        //      todo
    17791835                        //this.plugins = string.Empty;
    1780                         GlobalConfigObj.protectedSource = new object[0];
     1836                        GlobalConfigObj.protectedSource = new string[0];
    17811837                        GlobalConfigObj.removeDialogTabs = string.Empty;
    17821838                        GlobalConfigObj.removeFormatAttributes = "class,style,lang,width,height,align,hspace,valign";
    17831839                        GlobalConfigObj.removeFormatTags = "b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var";
     
    18341890                        GlobalConfigObj.startupMode = StartupMode.Wysiwyg;
    18351891                        GlobalConfigObj.startupOutlineBlocks = false;
    18361892                        GlobalConfigObj.startupShowBorders = true;
    1837                         GlobalConfigObj.stylesSet = "default";
     1893                        GlobalConfigObj.stylesSet = new string[] { "default" };
    18381894                        GlobalConfigObj.tabIndex = 0;
    18391895                        GlobalConfigObj.tabSpaces = 0;
    18401896                        GlobalConfigObj.templates_files = new string[] { "~/plugins/templates/templates/default.js" };
     
    18891945                        this.colorButton_backStyle = CKEditorConfig.GlobalConfig.colorButton_backStyle;
    18901946                        this.colorButton_colors = CKEditorConfig.GlobalConfig.colorButton_colors;
    18911947                        this.colorButton_foreStyle = CKEditorConfig.GlobalConfig.colorButton_foreStyle;
    1892                         this.contentsCss = ResoleResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);
     1948                        this.contentsCss = ResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);
    18931949                        this.contentsLangDirection = CKEditorConfig.GlobalConfig.contentsLangDirection;
    18941950                        this.contentsLanguage = CKEditorConfig.GlobalConfig.contentsLanguage;
    1895                         this.corePlugins = CKEditorConfig.GlobalConfig.corePlugins;
    18961951                        this.coreStyles_bold = CKEditorConfig.GlobalConfig.coreStyles_bold;
    18971952                        this.coreStyles_italic = CKEditorConfig.GlobalConfig.coreStyles_italic;
    18981953                        this.coreStyles_strike = CKEditorConfig.GlobalConfig.coreStyles_strike;
     
    20042059                        this.stylesSet = CKEditorConfig.GlobalConfig.stylesSet;
    20052060                        this.tabIndex = CKEditorConfig.GlobalConfig.tabIndex;
    20062061                        this.tabSpaces = CKEditorConfig.GlobalConfig.tabSpaces;
    2007                         this.templates_files = ResoleResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);
     2062                        this.templates_files = ResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);
    20082063                        this.templates_replaceContent = CKEditorConfig.GlobalConfig.templates_replaceContent;
    20092064                        this.theme = CKEditorConfig.GlobalConfig.theme;
    20102065                        this.toolbar = CKEditorConfig.GlobalConfig.toolbar;
     
    20212076                        if (CKEditorInstanceEventHandler != null)
    20222077                                this.CKEditorInstanceEventHandler = new List<object>(CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler);
    20232078                }
    2024                 private string[] ResoleResolveUrl(string[] value, string resolvedStr)
     2079                private string[] ResolveUrl(string[] value, string resolvedStr)
    20252080                {
    20262081                        for (int i = 0; i < value.Length; i++)
    20272082                                if (value[i].StartsWith("~") && !value[i].StartsWith(resolvedStr))
    20282083                                        value[i] = resolvedStr + value[i].Replace("~", "");
    20292084                        return value;
    20302085                }
     2086                private void ResolveParameters(string[] parIn, List<string> retVal, bool addAp)
     2087                {
     2088                        foreach (string item in parIn)
     2089                        {
     2090                                if (item.StartsWith("[") || item.EndsWith("]"))
     2091                                        ResolveParameters(item.Trim().Replace("[", string.Empty).Replace("]", string.Empty).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), retVal, addAp);
     2092                                else if (addAp && !item.StartsWith("'") && !item.EndsWith("'"))
     2093                                        retVal.Add("'" + item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) + "'");
     2094                                else
     2095                                        retVal.Add(item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty));
     2096                        }
     2097                }
     2098                private string ResolveParameters(string parIn, bool addAp)
     2099                {
     2100                        if (parIn.StartsWith("[") && parIn.EndsWith("]"))
     2101                                return parIn;
     2102                        else if (addAp && !parIn.StartsWith("'") && !parIn.EndsWith("'"))
     2103                                return "'" + parIn + "'";
     2104                        else
     2105                                return parIn;
     2106                }
    20312107                #endregion
    20322108        }
    20332109}
     2110 No newline at end of file
  • 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.")]
     
    628624                [DefaultValue(true)]
    629625                public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } }
    630626
     627                [PersistenceMode(PersistenceMode.Attribute)]
    631628                [Category("CKEditor Other Settings")]
    632629                [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.
    633630The styles may be defined in the page containing the editor, or can be loaded on demand from an external file. In the second case,
     
    635632Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file.
    636633Previously this setting was available as config.stylesCombo_stylesSet")]
    637634                [DefaultValue("default")]
    638                 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).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
     651                        }
     652                }
    639653
    640654                [Category("CKEditor Other Settings")]
    641655                [Description(@"Intructs the editor to add a number of spaces (&nbsp;) to the text when hitting the TAB key.
     
    643657                [DefaultValue(0)]
    644658                public int TabSpaces { get { return config.tabSpaces; } set { config.tabSpaces = value; } }
    645659
    646                 [PersistenceMode(PersistenceMode.Attribute)]
    647660                [Category("CKEditor Other Settings")]
    648661                [Description("The list of templates definition files to load.")]
    649662                [DefaultValue("~/ckeditor/plugins/templates/templates/default.js")]
     
    657670                                if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1);
    658671                                return retVal;
    659672                        }
    660                         set { config.templates_files = value.Split(new char[] { ',' }); }
     673                        set { config.templates_files = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); }
    661674                }
    662675
    663676                [Category("CKEditor Other Settings")]
     
    668681                [PersistenceMode(PersistenceMode.Attribute)]
    669682                [Category("CKEditor Basic Settings")]
    670683                [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.")]
    671                 [DefaultValue( "Full")]
     684                [DefaultValue("Full")]
    672685                [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
    673686                public string Toolbar
    674687                {
     
    703716                        }
    704717                        set
    705718                        {
    706                                 string[] valueTab = value.Split(new string[] { "\r\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
     719                                value = value.Trim();
     720                                if (value.StartsWith("[") && value.EndsWith("]"))
     721                                {
     722                                        config.toolbar = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty);
     723                                        return;
     724                                }
     725                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    707726                                if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic"))
    708727                                {
    709728                                        config.toolbar = valueTab[0];
     
    766785                        }
    767786                        set
    768787                        {
     788                                value = value.Trim();
     789                                if (value.StartsWith("[") && value.EndsWith("]"))
     790                                {
     791                                        config.toolbar_Basic = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     792                                        return;
     793                                }
    769794                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    770795                                object[] retVal = new object[valueTab.Length];
    771796                                try
     
    835860                        }
    836861                        set
    837862                        {
     863                                value = value.Trim();
     864                                if (value.StartsWith("[") && value.EndsWith("]"))
     865                                {
     866                                        config.toolbar_Full = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) };
     867                                        return;
     868                                }
    838869                                string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
    839870                                object[] retVal = new object[valueTab.Length];
    840871                                try
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy