Ticket #7283: 7283_1.patch
File 7283_1.patch, 26.5 KB (added by , 13 years ago) |
---|
-
trunk/_dev/msajax.js
28 28 oldPageLoad = window.pageLoad; 29 29 30 30 var fixValues = function () { 31 for (i = ids.length; i--;) { 32 var e = document.getElementById(ids[i]); 33 e.value = e.value.replace(/</g, '<').replace(/>/g, '>'); 31 if (typeof CKEDITOR == 'undefined'){ 32 for (i = ids.length; i--;) { 33 var e = document.getElementById(ids[i]); 34 e.value = e.value.replace(/</g, '<').replace(/>/g, '>'); 35 } 36 }else if(CKEDITOR.env.gecko){ 37 var span = new CKEDITOR.dom.element( 'span' ); 38 for (i = ids.length; i--;) { 39 var e = document.getElementById(ids[i]); 40 if(e.value != null && e.value != undefined && (e.value.indexOf('<') ==-1 || e.value.indexOf('>') ==-1)){ 41 span.setHtml( e.value ); 42 e.value = span.getText(); 43 } 44 } 34 45 } 35 46 }; 36 47 -
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 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 1531 1474 1532 /// <summary> 1475 1533 /// Whether the "Replace actual contents" checkbox is checked by default in the Templates dialog. 1476 1534 /// Default Value: true … … 1675 1733 GlobalConfigObj.contentsCss = new string[] { "~/contents.css" }; 1676 1734 GlobalConfigObj.contentsLangDirection = contentsLangDirections.Ui; 1677 1735 GlobalConfigObj.contentsLanguage = string.Empty; 1678 GlobalConfigObj.corePlugins = string.Empty;1679 1736 GlobalConfigObj.coreStyles_bold = @"{ element : 'strong', overrides : 'b' }"; 1680 1737 GlobalConfigObj.coreStyles_italic = @"{ element : 'em', overrides : 'i' }"; 1681 1738 GlobalConfigObj.coreStyles_strike = @"{ element : 'strike' }"; … … 1777 1834 GlobalConfigObj.pasteFromWordRemoveStyles = false; 1778 1835 // todo 1779 1836 //this.plugins = string.Empty; 1780 GlobalConfigObj.protectedSource = new object[0];1837 GlobalConfigObj.protectedSource = new string[0]; 1781 1838 GlobalConfigObj.removeDialogTabs = string.Empty; 1782 1839 GlobalConfigObj.removeFormatAttributes = "class,style,lang,width,height,align,hspace,valign"; 1783 1840 GlobalConfigObj.removeFormatTags = "b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var"; … … 1834 1891 GlobalConfigObj.startupMode = StartupMode.Wysiwyg; 1835 1892 GlobalConfigObj.startupOutlineBlocks = false; 1836 1893 GlobalConfigObj.startupShowBorders = true; 1837 GlobalConfigObj.stylesSet = "default";1894 GlobalConfigObj.stylesSet = new string[] { "default" }; 1838 1895 GlobalConfigObj.tabIndex = 0; 1839 1896 GlobalConfigObj.tabSpaces = 0; 1840 1897 GlobalConfigObj.templates_files = new string[] { "~/plugins/templates/templates/default.js" }; … … 1889 1946 this.colorButton_backStyle = CKEditorConfig.GlobalConfig.colorButton_backStyle; 1890 1947 this.colorButton_colors = CKEditorConfig.GlobalConfig.colorButton_colors; 1891 1948 this.colorButton_foreStyle = CKEditorConfig.GlobalConfig.colorButton_foreStyle; 1892 this.contentsCss = Resol eResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath);1949 this.contentsCss = ResolveUrl(CKEditorConfig.GlobalConfig.contentsCss, editorPath); 1893 1950 this.contentsLangDirection = CKEditorConfig.GlobalConfig.contentsLangDirection; 1894 1951 this.contentsLanguage = CKEditorConfig.GlobalConfig.contentsLanguage; 1895 this.corePlugins = CKEditorConfig.GlobalConfig.corePlugins;1896 1952 this.coreStyles_bold = CKEditorConfig.GlobalConfig.coreStyles_bold; 1897 1953 this.coreStyles_italic = CKEditorConfig.GlobalConfig.coreStyles_italic; 1898 1954 this.coreStyles_strike = CKEditorConfig.GlobalConfig.coreStyles_strike; … … 2004 2060 this.stylesSet = CKEditorConfig.GlobalConfig.stylesSet; 2005 2061 this.tabIndex = CKEditorConfig.GlobalConfig.tabIndex; 2006 2062 this.tabSpaces = CKEditorConfig.GlobalConfig.tabSpaces; 2007 this.templates_files = Resol eResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath);2063 this.templates_files = ResolveUrl(CKEditorConfig.GlobalConfig.templates_files, editorPath); 2008 2064 this.templates_replaceContent = CKEditorConfig.GlobalConfig.templates_replaceContent; 2009 2065 this.theme = CKEditorConfig.GlobalConfig.theme; 2010 2066 this.toolbar = CKEditorConfig.GlobalConfig.toolbar; … … 2021 2077 if (CKEditorInstanceEventHandler != null) 2022 2078 this.CKEditorInstanceEventHandler = new List<object>(CKEditorConfig.GlobalConfig.CKEditorInstanceEventHandler); 2023 2079 } 2024 private string[] Resol eResolveUrl(string[] value, string resolvedStr)2080 private string[] ResolveUrl(string[] value, string resolvedStr) 2025 2081 { 2026 2082 for (int i = 0; i < value.Length; i++) 2027 2083 if (value[i].StartsWith("~") && !value[i].StartsWith(resolvedStr)) 2028 2084 value[i] = resolvedStr + value[i].Replace("~", ""); 2029 2085 return value; 2030 2086 } 2087 private void ResolveParameters(string[] parIn, List<string> retVal, bool addAp) 2088 { 2089 foreach (string item in parIn) 2090 { 2091 if (item.StartsWith("[") || item.EndsWith("]")) 2092 ResolveParameters(item.Trim().Replace("[", string.Empty).Replace("]", string.Empty).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), retVal, addAp); 2093 else if (addAp && !item.StartsWith("'") && !item.EndsWith("'")) 2094 retVal.Add("'" + item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) + "'"); 2095 else 2096 retVal.Add(item.Trim().Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty)); 2097 } 2098 } 2099 private string ResolveParameters(string parIn, bool addAp) 2100 { 2101 if (parIn.StartsWith("[") && parIn.EndsWith("]")) 2102 return parIn; 2103 else if (addAp && !parIn.StartsWith("'") && !parIn.EndsWith("'")) 2104 return "'" + parIn + "'"; 2105 else 2106 return parIn; 2107 } 2031 2108 #endregion 2032 2109 } 2033 2110 } 2111 No newline at end of file -
trunk/CKEditor.NET/CKEditorControl.cs
21 21 [ToolboxData("<{0}:CKEditorControl runat=server></{0}:CKEditorControl>")] 22 22 [ParseChildren(false)] 23 23 [Designer("CKEditor.NET.CKEditorControlDesigner")] 24 public class CKEditorControl : TextBox 24 public class CKEditorControl : TextBox, IPostBackDataHandler 25 25 { 26 26 #region Changed TextBox Property 27 27 … … 32 32 { 33 33 get 34 34 { 35 if (!string.IsNullOrEmpty(base.Text))36 base.Text = base.Text.Replace("<", "<").Replace(">", ">").Replace("&", "&");37 35 return base.Text; 38 36 } 39 37 set 40 38 { 41 if (!string.IsNullOrEmpty(value))42 value = value.Replace("<", "<").Replace(">", ">").Replace("&", "&");43 39 base.Text = value; 44 40 } 45 41 } … … 153 149 154 150 [Category("CKEditor Other Settings")] 155 151 [Description("The editor tabindex value.")] 156 [DefaultValue(typeof(short), "0")]152 [DefaultValue(typeof(short), "0")] 157 153 public override short TabIndex { get { return (short)config.tabIndex; } set { config.tabIndex = value; } } 158 154 159 155 #region Encaspulate config … … 167 163 [Description("The minimum height to which the editor can reach using AutoGrow.")] 168 164 [DefaultValue(200)] 169 165 public int AutoGrowMinHeight { get { return config.autoGrow_minHeight; } set { config.autoGrow_minHeight = value; } } 170 166 171 167 [Category("CKEditor Other Settings")] 172 168 [Description("Whether the replaced element (usually a textarea) is to be updated automatically when posting the form containing the editor.")] 173 169 [DefaultValue(true)] … … 211 207 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 212 208 return retVal; 213 209 } 214 set { config.contentsCss = value. Split(new char[] { ',' }); }210 set { config.contentsCss = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); } 215 211 } 216 212 217 [Category("CKEditor Other Settings")][Description(@"The writting direction of the language used to write the editor contents. Allowed values are: 213 [Category("CKEditor Other Settings")] 214 [Description(@"The writting direction of the language used to write the editor contents. Allowed values are: 218 215 'ui' - which indicate content direction will be the same with the user interface language direction; 219 216 'ltr' - for Left-To-Right language (like English); 220 217 'rtl' - for Right-To-Left languages (like Arabic).")] … … 226 223 [DefaultValue("")] 227 224 public string ContentsLanguage { get { return config.contentsLanguage; } set { config.contentsLanguage = value; } } 228 225 229 [Category("CKEditor Other Settings")][Description(@"A comma separated list of plugins that are not related to editor instances. Reserved to plugins that extend the core code only.230 There are no ways to override this setting, except by editing the source code of CKEditor (_source/core/config.js).")]231 [DefaultValue("")]232 public string CorePlugins { get { return config.corePlugins; } set { config.corePlugins = value; } }233 234 226 [Category("CKEditor Basic Settings")] 235 227 [Description(@"The URL path for the custom configuration file to be loaded. If not overloaded with inline configurations, it defaults 236 228 to the ""config.js"" file present in the root of the CKEditor installation directory. … … 463 455 [Category("CKEditor Other Settings")] 464 456 [Description("Whether escape HTML when editor update original input element.")] 465 457 [DefaultValue(true)] 466 public bool HtmlEncodeOutput { get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } }458 public bool HtmlEncodeOutput { get { return config.htmlEncodeOutput; } set { config.htmlEncodeOutput = value; } } 467 459 468 460 [Category("CKEditor Other Settings")] 469 461 [Description(@"Whether the editor must output an empty value ("""") if it's contents is made by an empty paragraph only.")] … … 632 624 [DefaultValue(true)] 633 625 public bool StartupShowBorders { get { return config.startupShowBorders; } set { config.startupShowBorders = value; } } 634 626 627 [PersistenceMode(PersistenceMode.Attribute)] 635 628 [Category("CKEditor Other Settings")] 636 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. 637 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, … … 639 632 Otherwise, this setting has the ""name:url"" syntax, making it possible to set the URL from which loading the styles file. 640 633 Previously this setting was available as config.stylesCombo_stylesSet")] 641 634 [DefaultValue("default")] 642 public string StylesSet { get { return config.stylesSet; } set { config.stylesSet = value; } } 635 [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] 636 public string StylesSet 637 { 638 get 639 { 640 string retVal = string.Empty; 641 foreach (string item in config.stylesSet) retVal += item + ","; 642 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 643 return retVal; 644 } 645 set 646 { 647 if (value.Contains("{") && value.Contains("}")) 648 config.stylesSet = new string[] { value }; 649 else 650 config.stylesSet = value.Replace("\t", string.Empty).Split(new char[] { ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); 651 } 652 } 643 653 644 654 [Category("CKEditor Other Settings")] 645 655 [Description(@"Intructs the editor to add a number of spaces ( ) to the text when hitting the TAB key. … … 647 657 [DefaultValue(0)] 648 658 public int TabSpaces { get { return config.tabSpaces; } set { config.tabSpaces = value; } } 649 659 650 [PersistenceMode(PersistenceMode.Attribute)]651 660 [Category("CKEditor Other Settings")] 652 661 [Description("The list of templates definition files to load.")] 653 662 [DefaultValue("~/ckeditor/plugins/templates/templates/default.js")] … … 661 670 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 662 671 return retVal; 663 672 } 664 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); } 665 674 } 666 675 667 676 [Category("CKEditor Other Settings")] … … 672 681 [PersistenceMode(PersistenceMode.Attribute)] 673 682 [Category("CKEditor Basic Settings")] 674 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.")] 675 [DefaultValue( 684 [DefaultValue("Full")] 676 685 [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] 677 686 public string Toolbar 678 687 { … … 707 716 } 708 717 set 709 718 { 710 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); 711 726 if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic")) 712 727 { 713 728 config.toolbar = valueTab[0]; … … 770 785 } 771 786 set 772 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 } 773 794 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 774 795 object[] retVal = new object[valueTab.Length]; 775 796 try … … 839 860 } 840 861 set 841 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 } 842 869 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 843 870 object[] retVal = new object[valueTab.Length]; 844 871 try … … 999 1026 { 1000 1027 this.RegisterStartupScript(this.GetType(), "CKEDITOR_BASEPATH", string.Format("window.CKEDITOR_BASEPATH = '{0}/';\n", (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath)), true); 1001 1028 this.RegisterStartupScript(this.GetType(), "ckeditor", "<script src=\"" + (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.CKEditorJSFile) : this.CKEditorJSFile) + timestamp + "\" type=\"text/javascript\"></script>", false); 1002 if (HasMsAjax) 1003 { 1004 string scriptInit = string.Empty; 1029 string scriptInit = string.Empty; 1005 1030 1006 1007 1008 1009 scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'<').replace(/>/g,'>');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/</g,'<').replace(/>/g,'>');}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})();1031 // Sys.Application.add_load does not work on browsers != IE 1032 // http://msdn.microsoft.com/en-us/library/bb386417.aspx 1033 // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN). 1034 scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'<').replace(/>/g,'>');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){if(typeof CKEDITOR == 'undefined'){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/</g,'<').replace(/>/g,'>');}}else if(CKEDITOR.env.gecko){var span=new CKEDITOR.dom.element('span');for(i=ids.length;i--;){var e=document.getElementById(ids[i]);if(e.value!=null && e.value!=undefined && (e.value.indexOf('<')!=-1 || e.value.indexOf('>')!=-1)){span.setHtml(e.value);e.value=span.getText();}}}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})(); 1010 1035 "; 1011 1012 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1013 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1036 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1037 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1014 1038 ", this.ClientID), true); 1015 }1016 1039 string script = string.Empty; 1017 1040 if (this.config.CKEditorEventHandler != null) 1018 1041 foreach (object[] item in this.config.CKEditorEventHandler) … … 1020 1043 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.on('{0}',{1}); 1021 1044 ", item[0], item[1]); 1022 1045 } 1023 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1}); 1046 if (this.config.protectedSource != null && this.config.protectedSource.Length > 0) 1047 { 1048 string proSour = string.Empty; 1049 foreach (string item in this.config.protectedSource) 1050 proSour += @" 1051 ckeditor.config.protectedSource.push( " + item + " );"; 1052 script += string.Format(@"if(typeof CKEDITOR != 'undefined') {3} 1053 var ckeditor = CKEDITOR.replace('{0}',{1}); {2} 1054 {4}", this.ClientID, prepareJSON(), proSour, "{", "}"); 1055 } 1056 else 1057 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1}); 1024 1058 ", this.ClientID, prepareJSON()); 1025 1059 1026 if (HasMsAjax)1027 {1028 bool isInUpdatePanel = false;1029 Control con = this.Parent;1030 if (updatePanel != null)1031 while (con != null)1060 bool isInUpdatePanel = false; 1061 Control con = this.Parent; 1062 if (updatePanel != null) 1063 while (con != null) 1064 { 1065 if (con.GetType() == updatePanel) 1032 1066 { 1033 if (con.GetType() == updatePanel) 1034 { 1035 isInUpdatePanel = true; 1036 break; 1037 } 1038 con = con.Parent; 1067 isInUpdatePanel = true; 1068 break; 1039 1069 } 1040 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1041 } 1070 con = con.Parent; 1071 } 1072 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1042 1073 this.RegisterStartupScript(this.GetType(), "aspintegratorInitial_" + this.ClientID, script, true); 1043 1074 } 1044 1075 … … 1052 1083 } 1053 1084 1054 1085 #endregion 1086 1087 #region IPostBackDataHandler 1088 1089 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) 1090 { 1091 if (this.config.htmlEncodeOutput) 1092 { 1093 string postedValue = postCollection[postDataKey]; 1094 postedValue = postedValue.Replace("<", "<").Replace(">", ">").Replace("&", "&"); 1095 if (this.Text != postedValue) 1096 { 1097 this.Text = postedValue; 1098 return true; 1099 } 1100 } 1101 return false; 1102 } 1103 1104 void IPostBackDataHandler.RaisePostDataChangedEvent() { } 1105 1106 #endregion 1055 1107 } 1056 1108 1057 1109 public class CKEditorControlDesigner : System.Web.UI.Design.ControlDesigner