Ticket #7283: 7283.patch
File 7283.patch, 14.6 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, '>'); 34 } 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 } 35 37 }; 36 38 37 39 window.pageLoad = function(sender, args) { -
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).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, 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).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, 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. … … 661 671 if (retVal.EndsWith(",")) retVal = retVal.Remove(retVal.Length - 1); 662 672 return retVal; 663 673 } 664 set { config.templates_files = value. Split(new char[] { ',' }); }674 set { config.templates_files = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } 665 675 } 666 676 667 677 [Category("CKEditor Other Settings")] … … 672 682 [PersistenceMode(PersistenceMode.Attribute)] 673 683 [Category("CKEditor Basic Settings")] 674 684 [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( 685 [DefaultValue("Full")] 676 686 [Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor))] 677 687 public string Toolbar 678 688 { … … 707 717 } 708 718 set 709 719 { 710 string[] valueTab = value.Split(new string[] { "\r\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 720 value = value.Trim(); 721 if (value.StartsWith("[") && value.EndsWith("]")) 722 { 723 config.toolbar = value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty); 724 return; 725 } 726 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 711 727 if (valueTab.Length == 1 && (valueTab[0] == "Full" || valueTab[0] == "Basic")) 712 728 { 713 729 config.toolbar = valueTab[0]; … … 770 786 } 771 787 set 772 788 { 789 value = value.Trim(); 790 if (value.StartsWith("[") && value.EndsWith("]")) 791 { 792 config.toolbar_Basic = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) }; 793 return; 794 } 773 795 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 774 796 object[] retVal = new object[valueTab.Length]; 775 797 try … … 839 861 } 840 862 set 841 863 { 864 value = value.Trim(); 865 if (value.StartsWith("[") && value.EndsWith("]")) 866 { 867 config.toolbar_Full = new object[] { value.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty) }; 868 return; 869 } 842 870 string[] valueTab = value.Split(new string[] { "\r\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries); 843 871 object[] retVal = new object[valueTab.Length]; 844 872 try … … 999 1027 { 1000 1028 this.RegisterStartupScript(this.GetType(), "CKEDITOR_BASEPATH", string.Format("window.CKEDITOR_BASEPATH = '{0}/';\n", (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath)), true); 1001 1029 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; 1030 string scriptInit = string.Empty; 1005 1031 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);})();1032 // Sys.Application.add_load does not work on browsers != IE 1033 // http://msdn.microsoft.com/en-us/library/bb386417.aspx 1034 // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN). 1035 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,'>');}}};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 1036 "; 1011 1012 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1013 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1037 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1038 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1014 1039 ", this.ClientID), true); 1015 }1016 1040 string script = string.Empty; 1017 1041 if (this.config.CKEditorEventHandler != null) 1018 1042 foreach (object[] item in this.config.CKEditorEventHandler) … … 1020 1044 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.on('{0}',{1}); 1021 1045 ", item[0], item[1]); 1022 1046 } 1023 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1}); 1047 if (this.config.protectedSource != null && this.config.protectedSource.Length > 0) 1048 { 1049 string proSour = string.Empty; 1050 foreach (string item in this.config.protectedSource) 1051 proSour += @" 1052 ckeditor.config.protectedSource.push( " + item + " );"; 1053 script += string.Format(@"if(typeof CKEDITOR != 'undefined') {3} 1054 var ckeditor = CKEDITOR.replace('{0}',{1}); {2} 1055 {4}", this.ClientID, prepareJSON(), proSour, "{", "}"); 1056 } 1057 else 1058 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1}); 1024 1059 ", this.ClientID, prepareJSON()); 1025 1060 1026 if (HasMsAjax)1027 {1028 bool isInUpdatePanel = false;1029 Control con = this.Parent;1030 if (updatePanel != null)1031 while (con != null)1061 bool isInUpdatePanel = false; 1062 Control con = this.Parent; 1063 if (updatePanel != null) 1064 while (con != null) 1065 { 1066 if (con.GetType() == updatePanel) 1032 1067 { 1033 if (con.GetType() == updatePanel) 1034 { 1035 isInUpdatePanel = true; 1036 break; 1037 } 1038 con = con.Parent; 1068 isInUpdatePanel = true; 1069 break; 1039 1070 } 1040 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1041 } 1071 con = con.Parent; 1072 } 1073 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1042 1074 this.RegisterStartupScript(this.GetType(), "aspintegratorInitial_" + this.ClientID, script, true); 1043 1075 } 1044 1076 … … 1052 1084 } 1053 1085 1054 1086 #endregion 1087 1088 #region IPostBackDataHandler 1089 1090 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) 1091 { 1092 if (this.config.htmlEncodeOutput) 1093 { 1094 string postedValue = postCollection[postDataKey]; 1095 postedValue = postedValue.Replace("<", "<").Replace(">", ">").Replace("&", "&"); 1096 if (this.Text != postedValue) 1097 { 1098 this.Text = postedValue; 1099 return true; 1100 } 1101 } 1102 return false; 1103 } 1104 1105 void IPostBackDataHandler.RaisePostDataChangedEvent() { } 1106 1107 #endregion 1055 1108 } 1056 1109 1057 1110 public class CKEditorControlDesigner : System.Web.UI.Design.ControlDesigner