Ticket #7285: 7285_2.patch
File 7285_2.patch, 18.8 KB (added by , 13 years ago) |
---|
-
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 sbJSON.Append("\"" + EscapeStringForJavaScript(valueToJSON[0]).TrimStart(new char[] { '\'' }).TrimEnd(new char[] { '\'' }) + "\""); 189 sbJSON.Append(", "); 190 } 191 continue; 192 } 181 193 else if (customName == "on" && ((object[])propertyInfo.GetValue(obj, new object[0])).Length > 0) 182 194 { 183 195 object[] objArray = (object[])((object[])propertyInfo.GetValue(obj, new object[0]))[0]; … … 201 213 continue; 202 214 } 203 215 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 } 204 229 GetFieldOrPropertyValue(ref sbJSON, propertyInfo.GetValue(obj, new object[0]), removeEnters, isObject); 205 230 sbJSON.Append(", "); 206 231 } … … 446 471 /// the contents are to be used. 447 472 /// Default Value: new string[] { "~/contents.css" }; 448 473 /// </summary> 449 [CKSerializable]450 474 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 } 451 485 452 486 /// <summary> 453 487 /// The writting direction of the language used to write the editor contents. Allowed values are: … … 472 506 public string contentsLanguage { get; set; } 473 507 474 508 /// <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 509 /// The style definition to be used to apply the bold style in the text. 483 510 /// Default Value: "{ element : 'strong', overrides : 'b' }" 484 511 /// </summary> … … 823 850 /// For example, "Bigger Font/14px" will be displayed as "Bigger Font" in the list, but will be outputted as "14px". 824 851 /// 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 852 /// </summary> 826 [CKSerializable (IsObject = true)]853 [CKSerializable] 827 854 public string fontSize_sizes { get; set; } 828 855 829 856 /// <summary> … … 988 1015 /// 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 1016 /// Default Value: [] 990 1017 /// </summary> 991 [CKSerializable]992 1018 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 } 993 1029 994 1030 /// <summary> 995 1031 /// Size of each indentation step … … 1094 1130 /// 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 1131 /// Default Value: [] 1096 1132 /// </summary> 1097 [CKSerializable(IsObject = true)] 1098 public object[] protectedSource { get; set; } 1133 public string[] protectedSource { get; set; } 1099 1134 1100 1135 /// <summary> 1101 1136 /// The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them. … … 1446 1481 /// Previously this setting was available as config.stylesCombo_stylesSet 1447 1482 /// Default Value: ["'default'"] 1448 1483 /// </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 } 1452 1500 /// <summary> 1453 1501 /// The editor tabindex value. 1454 1502 /// Default Value: 0 … … 1468 1516 /// The list of templates definition files to load. 1469 1517 /// Default Value: new string[] { "~/plugins/templates/templates/default.js" }; 1470 1518 /// </summary> 1471 [CKSerializable]1472 1519 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 } 1473 1530 1474 1531 /// <summary> 1475 1532 /// Whether the "Replace actual contents" checkbox is checked by default in the Templates dialog. … … 1675 1732 GlobalConfigObj.contentsCss = new string[] { "~/contents.css" }; 1676 1733 GlobalConfigObj.contentsLangDirection = contentsLangDirections.Ui; 1677 1734 GlobalConfigObj.contentsLanguage = string.Empty; 1678 GlobalConfigObj.corePlugins = string.Empty;1679 1735 GlobalConfigObj.coreStyles_bold = @"{ element : 'strong', overrides : 'b' }"; 1680 1736 GlobalConfigObj.coreStyles_italic = @"{ element : 'em', overrides : 'i' }"; 1681 1737 GlobalConfigObj.coreStyles_strike = @"{ element : 'strike' }"; … … 1777 1833 GlobalConfigObj.pasteFromWordRemoveStyles = false; 1778 1834 // todo 1779 1835 //this.plugins = string.Empty; 1780 GlobalConfigObj.protectedSource = new object[0];1836 GlobalConfigObj.protectedSource = new string[0]; 1781 1837 GlobalConfigObj.removeDialogTabs = string.Empty; 1782 1838 GlobalConfigObj.removeFormatAttributes = "class,style,lang,width,height,align,hspace,valign"; 1783 1839 GlobalConfigObj.removeFormatTags = "b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var"; … … 1834 1890 GlobalConfigObj.startupMode = StartupMode.Wysiwyg; 1835 1891 GlobalConfigObj.startupOutlineBlocks = false; 1836 1892 GlobalConfigObj.startupShowBorders = true; 1837 GlobalConfigObj.stylesSet = "default";1893 GlobalConfigObj.stylesSet = new string[] { "default" }; 1838 1894 GlobalConfigObj.tabIndex = 0; 1839 1895 GlobalConfigObj.tabSpaces = 0; 1840 1896 GlobalConfigObj.templates_files = new string[] { "~/plugins/templates/templates/default.js" }; … … 1889 1945 this.colorButton_backStyle = CKEditorConfig.GlobalConfig.colorButton_backStyle; 1890 1946 this.colorButton_colors = CKEditorConfig.GlobalConfig.colorButton_colors; 1891 1947 this.colorButton_foreStyle = CKEditorConfig.GlobalConfig.colorButton_foreStyle; 1892 this.contentsCss = Resol eResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);1948 this.contentsCss = ResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath); 1893 1949 this.contentsLangDirection = CKEditorConfig.GlobalConfig.contentsLangDirection; 1894 1950 this.contentsLanguage = CKEditorConfig.GlobalConfig.contentsLanguage; 1895 this.corePlugins = CKEditorConfig.GlobalConfig.corePlugins;1896 1951 this.coreStyles_bold = CKEditorConfig.GlobalConfig.coreStyles_bold; 1897 1952 this.coreStyles_italic = CKEditorConfig.GlobalConfig.coreStyles_italic; 1898 1953 this.coreStyles_strike = CKEditorConfig.GlobalConfig.coreStyles_strike; … … 2004 2059 this.stylesSet = CKEditorConfig.GlobalConfig.stylesSet; 2005 2060 this.tabIndex = CKEditorConfig.GlobalConfig.tabIndex; 2006 2061 this.tabSpaces = CKEditorConfig.GlobalConfig.tabSpaces; 2007 this.templates_files = Resol eResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);2062 this.templates_files = ResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath); 2008 2063 this.templates_replaceContent = CKEditorConfig.GlobalConfig.templates_replaceContent; 2009 2064 this.theme = CKEditorConfig.GlobalConfig.theme; 2010 2065 this.toolbar = CKEditorConfig.GlobalConfig.toolbar; … … 2021 2076 if (CKEditorInstanceEventHandler != null) 2022 2077 this.CKEditorInstanceEventHandler = new List<object>(CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler); 2023 2078 } 2024 private string[] Resol eResolveUrl(string[] value, string resolvedStr)2079 private string[] ResolveUrl(string[] value, string resolvedStr) 2025 2080 { 2026 2081 for (int i = 0; i < value.Length; i++) 2027 2082 if (value[i].StartsWith("~") && !value[i].StartsWith(resolvedStr)) 2028 2083 value[i] = resolvedStr + value[i].Replace("~", ""); 2029 2084 return value; 2030 2085 } 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 } 2031 2107 #endregion 2032 2108 } 2033 2109 } 2110 No newline at end of file -
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.")] … … 628 624 [DefaultValue(true)] 629 625 public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } } 630 626 627 [PersistenceMode(PersistenceMode.Attribute)] 631 628 [Category("CKEditor Other Settings")] 632 629 [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. 633 630 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, … … 635 632 Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file. 636 633 Previously this setting was available as config.stylesCombo_stylesSet")] 637 634 [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 } 639 653 640 654 [Category("CKEditor Other Settings")] 641 655 [Description(@"Intructs the editor to add a number of spaces ( ) to the text when hitting the TAB key. … … 643 657 [DefaultValue(0)] 644 658 public int TabSpaces { get { return config.tabSpaces; } set { config.tabSpaces = value; } } 645 659 646 [PersistenceMode(PersistenceMode.Attribute)]647 660 [Category("CKEditor Other Settings")] 648 661 [Description("The list of templates definition files to load.")] 649 662 [DefaultValue("~/ckeditor/plugins/templates/templates/default.js")] … … 657 670 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 658 671 return retVal; 659 672 } 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); } 661 674 } 662 675 663 676 [Category("CKEditor Other Settings")] … … 668 681 [PersistenceMode(PersistenceMode.Attribute)] 669 682 [Category("CKEditor Basic Settings")] 670 683 [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( 684 [DefaultValue("Full")] 672 685 [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] 673 686 public string Toolbar 674 687 { … … 703 716 } 704 717 set 705 718 { 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); 707 726 if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic")) 708 727 { 709 728 config.toolbar = valueTab[0]; … … 766 785 } 767 786 set 768 787 { 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 } 769 794 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 770 795 object[] retVal = new object[valueTab.Length]; 771 796 try … … 835 860 } 836 861 set 837 862 { 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 } 838 869 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 839 870 object[] retVal = new object[valueTab.Length]; 840 871 try