From b9d3529f863a45c536622bd1cc4e6f755f3ff8f0 Mon Sep 17 00:00:00 2001 From: kenny Date: Mon, 21 Jun 2010 11:44:35 +0000 Subject: [PATCH] Fixes 27750 and 27787: Disable CodeMirror in IE due to the automatic hyperlinking "feature" in content editable areas which effectively removes quotes around whatever it believe is a link. [TFS Changeset #70466] --- components/umbraco.controls/CodeArea.cs | 27 ++++++++++++++----- .../config/umbracoSettings.config | 1 + .../config/umbracoSettings.config | 6 ++--- .../presentation/umbraco/config/lang/en.xml | 1 + 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/components/umbraco.controls/CodeArea.cs b/components/umbraco.controls/CodeArea.cs index d25121c83f..0691408262 100644 --- a/components/umbraco.controls/CodeArea.cs +++ b/components/umbraco.controls/CodeArea.cs @@ -46,6 +46,14 @@ namespace umbraco.uicontrols { } } + public bool CodeMirrorEnabled + { + get + { + return !UmbracoSettings.ScriptDisableEditor && HttpContext.Current.Request.Browser.Browser != "IE"; + } + } + public EditorType CodeBase { get; set; } public string ClientSaveMethod { get; set; } @@ -56,7 +64,7 @@ namespace umbraco.uicontrols { base.OnInit(e); EnsureChildControls(); - if (!UmbracoSettings.ScriptDisableEditor) + if (CodeMirrorEnabled) { ClientDependencyLoader.Instance.RegisterDependency("CodeMirror/js/codemirror.js", "UmbracoClient", ClientDependencyType.Javascript); ClientDependencyLoader.Instance.RegisterDependency("CodeArea/styles.css", "UmbracoClient", ClientDependencyType.Css); @@ -69,12 +77,11 @@ namespace umbraco.uicontrols { CodeTextBox = new TextBox(); CodeTextBox.ID = "CodeTextBox"; - if (UmbracoSettings.ScriptDisableEditor) + if (!CodeMirrorEnabled) { CodeTextBox.Attributes.Add("class", "codepress"); CodeTextBox.Attributes.Add("wrap", "off"); } - else CodeTextBox.TextMode = TextBoxMode.MultiLine; @@ -91,7 +98,7 @@ namespace umbraco.uicontrols { { get { - if (UmbracoSettings.ScriptDisableEditor) + if (!CodeMirrorEnabled) return CodeTextBox.ClientID; else return base.ClientID; @@ -103,7 +110,7 @@ namespace umbraco.uicontrols { EnsureChildControls(); var jsEventCode = ""; - if (UmbracoSettings.ScriptDisableEditor) + if (!CodeMirrorEnabled) { CodeTextBox.RenderControl(writer); jsEventCode = RenderBasicEditor(); @@ -125,7 +132,7 @@ namespace umbraco.uicontrols { if (this.AutoResize) { - if (!UmbracoSettings.ScriptDisableEditor) + if (CodeMirrorEnabled) { //reduce the width if using code mirror because of the line numbers OffSetX += 20; @@ -134,7 +141,7 @@ namespace umbraco.uicontrols { jsEventCode += @" //create the editor - var UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + UmbracoSettings.ScriptDisableEditor.ToString().ToLower() + @", '" + this.ClientID + @"'); + var UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (!CodeMirrorEnabled).ToString().ToLower() + @", '" + this.ClientID + @"'); var m_textEditor = jQuery('#" + this.ClientID + @"'); @@ -143,6 +150,12 @@ namespace umbraco.uicontrols { jQuery(window).resize(function(){ resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); }); jQuery(document).ready(function(){ resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); }); "; + + if (!UmbracoSettings.ScriptDisableEditor && HttpContext.Current.Request.Browser.Browser == "IE") + { + jsEventCode += "jQuery('

" + ui.Text("codemirroriewarning") +"

').insertAfter('#" + this.ClientID + "');"; + } + } jsEventCode = string.Format(@"", jsEventCode); diff --git a/config templates/config/umbracoSettings.config b/config templates/config/umbracoSettings.config index a8d0c29617..7991b29a49 100644 --- a/config templates/config/umbracoSettings.config +++ b/config templates/config/umbracoSettings.config @@ -13,6 +13,7 @@ js,xml + false diff --git a/umbraco/presentation/config/umbracoSettings.config b/umbraco/presentation/config/umbracoSettings.config index bc06b61673..aacd551e8d 100644 --- a/umbraco/presentation/config/umbracoSettings.config +++ b/umbraco/presentation/config/umbracoSettings.config @@ -12,7 +12,8 @@ /scripts js,xml - + + false @@ -23,9 +24,8 @@ - 1050 + 1 - robot@umbraco.dk diff --git a/umbraco/presentation/umbraco/config/lang/en.xml b/umbraco/presentation/umbraco/config/lang/en.xml index 1b53cfc6cf..3fb4664d42 100644 --- a/umbraco/presentation/umbraco/config/lang/en.xml +++ b/umbraco/presentation/umbraco/config/lang/en.xml @@ -370,6 +370,7 @@ The python script has not been saved, because it contained error(s) Please fill both alias and name on the new propertytype! There is a problem with read/write access to a specific file or folder + NOTE! Even though CodeMirror is enabled by configuration, it is disabled in IE due to automatic hyperlinking. Xslt saved