Ticket #7285: 7285_3.patch
File 7285_3.patch, 19.1 KB (added by , 13 years ago) |
---|
-
trunk/CKEditor.NET/CKEditorConfig.cs
178 178 if (customName == "ExtraOptions") 179 179 foreach (object[] item in (object[])propertyInfo.GetValue(obj, new object[0])) 180 180 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 } 181 197 else if (customName == "on" && ((object[])propertyInfo.GetValue(obj, new object[0])).Length > 0) 182 198 { 183 199 object[] objArray = (object[])((object[])propertyInfo.GetValue(obj, new object[0]))[0]; … … 201 217 continue; 202 218 } 203 219 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 } 204 233 GetFieldOrPropertyValue(ref sbJSON, propertyInfo.GetValue(obj, new object[0]), removeEnters, isObject); 205 234 sbJSON.Append(", "); 206 235 } … … 446 475 /// the contents are to be used. 447 476 /// Default Value: new string[] { "~/contents.css" }; 448 477 /// </summary> 449 [CKSerializable]450 478 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 } 451 489 452 490 /// <summary> 453 491 /// The writting direction of the language used to write the editor contents. Allowed values are: … … 472 510 public string contentsLanguage { get; set; } 473 511 474 512 /// <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>482 513 /// The style definition to be used to apply the bold style in the text. 483 514 /// Default Value: "{ element : 'strong', overrides : 'b' }" 484 515 /// </summary> … … 823 854 /// For example, "Bigger Font/14px" will be displayed as "Bigger Font" in the list, but will be outputted as "14px". 824 855 /// 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" 825 856 /// </summary> 826 [CKSerializable (IsObject = true)]857 [CKSerializable] 827 858 public string fontSize_sizes { get; set; } 828 859 829 860 /// <summary> … … 988 1019 /// 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. 989 1020 /// Default Value: [] 990 1021 /// </summary> 991 [CKSerializable]992 1022 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 } 993 1033 994 1034 /// <summary> 995 1035 /// Size of each indentation step … … 1094 1134 /// 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. 1095 1135 /// Default Value: [] 1096 1136 /// </summary> 1097 public string 1098 1137 public string[] protectedSource { get; set; } 1138 1099 1139 /// <summary> 1100 1140 /// The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them. 1101 1141 /// Separate each pair with semicolon (see example). Note: All names are case-sensitive. … … 1445 1485 /// Previously this setting was available as config.stylesCombo_stylesSet 1446 1486 /// Default Value: ["'default'"] 1447 1487 /// </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 } 1451 1504 /// <summary> 1452 1505 /// The editor tabindex value. 1453 1506 /// Default Value: 0 … … 1467 1520 /// The list of templates definition files to load. 1468 1521 /// Default Value: new string[] { "~/plugins/templates/templates/default.js" }; 1469 1522 /// </summary> 1470 [CKSerializable]1471 1523 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 } 1472 1534 1473 1535 /// <summary> 1474 1536 /// Whether the "Replace actual contents" checkbox is checked by default in the Templates dialog. … … 1674 1736 GlobalConfigObj.contentsCss = new string[] { "~/contents.css" }; 1675 1737 GlobalConfigObj.contentsLangDirection = contentsLangDirections.Ui; 1676 1738 GlobalConfigObj.contentsLanguage = string.Empty; 1677 GlobalConfigObj.corePlugins = string.Empty;1678 1739 GlobalConfigObj.coreStyles_bold = @"{ element : 'strong', overrides : 'b' }"; 1679 1740 GlobalConfigObj.coreStyles_italic = @"{ element : 'em', overrides : 'i' }"; 1680 1741 GlobalConfigObj.coreStyles_strike = @"{ element : 'strike' }"; … … 1833 1894 GlobalConfigObj.startupMode = StartupMode.Wysiwyg; 1834 1895 GlobalConfigObj.startupOutlineBlocks = false; 1835 1896 GlobalConfigObj.startupShowBorders = true; 1836 GlobalConfigObj.stylesSet = "default";1897 GlobalConfigObj.stylesSet = new string[] { "default" }; 1837 1898 GlobalConfigObj.tabIndex = 0; 1838 1899 GlobalConfigObj.tabSpaces = 0; 1839 1900 GlobalConfigObj.templates_files = new string[] { "~/plugins/templates/templates/default.js" }; … … 1888 1949 this.colorButton_backStyle = CKEditorConfig.GlobalConfig.colorButton_backStyle; 1889 1950 this.colorButton_colors = CKEditorConfig.GlobalConfig.colorButton_colors; 1890 1951 this.colorButton_foreStyle = CKEditorConfig.GlobalConfig.colorButton_foreStyle; 1891 this.contentsCss = Resol eResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);1952 this.contentsCss = ResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath); 1892 1953 this.contentsLangDirection = CKEditorConfig.GlobalConfig.contentsLangDirection; 1893 1954 this.contentsLanguage = CKEditorConfig.GlobalConfig.contentsLanguage; 1894 this.corePlugins = CKEditorConfig.GlobalConfig.corePlugins;1895 1955 this.coreStyles_bold = CKEditorConfig.GlobalConfig.coreStyles_bold; 1896 1956 this.coreStyles_italic = CKEditorConfig.GlobalConfig.coreStyles_italic; 1897 1957 this.coreStyles_strike = CKEditorConfig.GlobalConfig.coreStyles_strike; … … 2003 2063 this.stylesSet = CKEditorConfig.GlobalConfig.stylesSet; 2004 2064 this.tabIndex = CKEditorConfig.GlobalConfig.tabIndex; 2005 2065 this.tabSpaces = CKEditorConfig.GlobalConfig.tabSpaces; 2006 this.templates_files = Resol eResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);2066 this.templates_files = ResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath); 2007 2067 this.templates_replaceContent = CKEditorConfig.GlobalConfig.templates_replaceContent; 2008 2068 this.theme = CKEditorConfig.GlobalConfig.theme; 2009 2069 this.toolbar = CKEditorConfig.GlobalConfig.toolbar; … … 2020 2080 if (CKEditorInstanceEventHandler != null) 2021 2081 this.CKEditorInstanceEventHandler = new List<object>(CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler); 2022 2082 } 2023 private string[] Resol eResolveUrl(string[] value, string resolvedStr)2083 private string[] ResolveUrl(string[] value, string resolvedStr) 2024 2084 { 2025 2085 for (int i = 0; i < value.Length; i++) 2026 2086 if (value[i].StartsWith("~") && !value[i].StartsWith(resolvedStr)) 2027 2087 value[i] = resolvedStr + value[i].Replace("~", ""); 2028 2088 return value; 2029 2089 } 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 } 2030 2111 #endregion 2031 2112 } 2032 2113 } 2114 No newline at end of file -
trunk/CKEditor.NET/CKEditorControl.cs
149 149 150 150 [Category("CKEditor Other Settings")] 151 151 [Description("The editor tabindex value.")] 152 [DefaultValue(typeof(short), "0")]152 [DefaultValue(typeof(short), "0")] 153 153 public override short TabIndex { get { return (short)config.tabIndex; } set { config.tabIndex = value; } } 154 154 155 155 #region Encaspulate config … … 163 163 [Description("The minimum height to which the editor can reach using AutoGrow.")] 164 164 [DefaultValue(200)] 165 165 public int AutoGrowMinHeight { get { return config.autoGrow_minHeight; } set { config.autoGrow_minHeight = value; } } 166 166 167 167 [Category("CKEditor Other Settings")] 168 168 [Description("Whether the replaced element (usually a textarea) is to be updated automatically when posting the form containing the editor.")] 169 169 [DefaultValue(true)] … … 207 207 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 208 208 return retVal; 209 209 } 210 set { config.contentsCss = value. Split(new char[] { ',' }); }210 set { config.contentsCss = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); } 211 211 } 212 212 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: 214 215 'ui' - which indicate content direction will be the same with the user interface language direction; 215 216 'ltr' - for Left-To-Right language (like English); 216 217 'rtl' - for Right-To-Left languages (like Arabic).")] … … 222 223 [DefaultValue("")] 223 224 public string ContentsLanguage { get { return config.contentsLanguage; } set { config.contentsLanguage = value; } } 224 225 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 230 226 [Category("CKEditor Basic Settings")] 231 227 [Description(@"The URL path for the custom configuration file to be loaded. If not overloaded with inline configurations, it defaults 232 228 to the ""config.js"" file present in the root of the CKEditor installation directory. … … 459 455 [Category("CKEditor Other Settings")] 460 456 [Description("Whether escape HTML when editor update original input element.")] 461 457 [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; } } 463 459 464 460 [Category("CKEditor Other Settings")] 465 461 [Description(@"Whether the editor must output an empty value ("""") if it's contents is made by an empty paragraph only.")] … … 582 578 public bool ScaytAutoStartup { get { return config.scayt_autoStartup; } set { config.scayt_autoStartup = value; } } 583 579 584 580 [Category("CKEditor Other Settings")] 585 [DefaultValue("ID of bottom cntrol's shared")] 581 [Description("ID of bottom cntrol's shared")] 582 [DefaultValue("")] 586 583 public string SharedSpacesBottom { get { return config.sharedSpacesBottom; } set { config.sharedSpacesBottom = value; } } 587 584 588 585 [Category("CKEditor Other Settings")] 589 [DefaultValue("ID of top cntrol's shared")] 586 [Description("ID of top cntrol's shared")] 587 [DefaultValue("")] 590 588 public string SharedSpacesTop { get { return config.sharedSpacesTop; } set { config.sharedSpacesTop = value; } } 591 589 592 590 [Category("CKEditor Other Settings")] … … 618 616 [DefaultValue(true)] 619 617 public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } } 620 618 619 [PersistenceMode(PersistenceMode.Attribute)] 621 620 [Category("CKEditor Other Settings")] 622 621 [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. 623 622 The styles may be defined in the page containing the editor, or can be loaded on demand from an external file. In the second case, … … 625 624 Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file. 626 625 Previously this setting was available as config.stylesCombo_stylesSet")] 627 626 [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 } 629 645 630 646 [Category("CKEditor Other Settings")] 631 647 [Description(@"Intructs the editor to add a number of spaces ( ) to the text when hitting the TAB key. … … 647 663 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 648 664 return retVal; 649 665 } 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); } 651 667 } 652 668 653 669 [Category("CKEditor Other Settings")] … … 658 674 [PersistenceMode(PersistenceMode.Attribute)] 659 675 [Category("CKEditor Basic Settings")] 660 676 [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( 677 [DefaultValue("Full")] 662 678 [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] 663 679 public string Toolbar 664 680 { … … 693 709 } 694 710 set 695 711 { 696 string[] valueTab = value.Split(new string[] { "\r\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);697 if (value Tab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic"))712 value = value.Trim(); 713 if (value.StartsWith("[") && value.EndsWith("]")) 698 714 { 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 { 699 721 config.toolbar = valueTab[0]; 700 722 return; 701 723 } … … 756 778 } 757 779 set 758 780 { 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 } 759 787 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 760 788 object[] retVal = new object[valueTab.Length]; 761 789 try … … 825 853 } 826 854 set 827 855 { 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 } 828 862 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 829 863 object[] retVal = new object[valueTab.Length]; 830 864 try