Can't update H1 tags in config files

Last post 09-03-2010, 10:00 AM by StevenLockey. 9 replies.
Sort Posts: Previous Next
  •  08-02-2010, 6:38 AM 62929

    Can't update H1 tags in config files

    Hi,
       we are trying to remove the padding and margins from the headings produced by the editor. 
     
    We would expect that to do this we could modify the common.config file for the editor:
     
         <FormatBlock>
                <item text="[[DIV]]" value="&lt;DIV&gt;">
                    <html><![CDATA[[[DIV]]]]></html>
                </item>
                <item text="[[Normal]]" value="&lt;P&gt;">
                    <html><![CDATA[[[Normal]]]]></html>
                </item>
                <item text="[[Heading 1]]" value="&lt;H1&gt;">
                    <html><![CDATA[<b style='font-size:24pt;'>[[Heading 1]]</b>]]></html>
                </item>
                <item text="[[Heading 2]]" value="&lt;H2&gt;">
                    <html><![CDATA[<b style='font-size:18pt;'>[[Heading 2]]</b>]]></html>
                </item>
                <item text="[[Heading 3]]" value="&lt;H3&gt;">
                    <html><![CDATA[<b style='font-size:15pt;'>[[Heading 3]]</b>]]></html>
                </item>
                <item text="[[Heading 4]]" value="&lt;H4&gt;">
                    <html><![CDATA[<b style='font-size:12pt;'>[[Heading 4]]</b>]]></html>
                </item>
                <item text="[[Heading 5]]" value="&lt;H5&gt;">
                    <html><![CDATA[<b style='font-size:9pt;'>[[Heading 5]]</b>]]></html>
                </item>
                <item text="[[Heading 6]]" value="&lt;H6&gt;">
                    <html><![CDATA[<b style='font-size:7pt;'>[[Heading 6]]</b>]]></html>
                </item>
                <item text="[[Address]]" value="&lt;Address&gt;">
                    <html><![CDATA[[[Address]]]]></html>
                </item>
                <item text="[[MenuList]]" value="&lt;MENU&gt;">
                    <html><![CDATA[[[MenuList]]]]></html>
                </item>
                <item text="[[Formatted]]" value="&lt;PRE&gt;">
                    <html><![CDATA[[[Formatted]]]]></html>
                </item>
                <item text="[[Definition Term]]" value="&lt;DT&gt;">
                    <html><![CDATA[[[Definition Term]]]]></html>
                </item>
            </FormatBlock>
     
    Is the section that we are looking at, we'd like the change all the heading tags to include style="padding:0; margin:0;" in them however whenever we add anythign to the h1, even just a space, when you try and select that heading in the editor it just throws and error and reverts back to whatever heading style it was using previously. 
     
     Example of change:
     
             <item text="[[Heading 1]]" value="&lt;H1 style='padding:0;margin:0;'&gt;">
                    <html><![CDATA[<b style='font-size:24pt;'>[[Heading 1]]</b>]]></html>
                </item>
     
    We've tried escaping all the : ' and ; to their html entites to see if that helped as well and it still did nothing. 
     
    Unfortunatly we can't edit the Headings directly in the css as it would affect other pages in the site which we need to restyle first.
    We also can't use the inline styles to sort this out or anything like that since it places the span with them on inside the heading tag like this:
    <h1><span style=".....">fgsdgdfg</span></h1>
    so doesn't affect the paddings or margins on the main style.
     
    If theres a solution to this please let me know, I can't find the code that is validating the heading tags either to force it to add the styles in there which would of worked but I think its in the obfuscated files.
     
     
    Thanks
  •  08-03-2010, 8:58 AM 63018 in reply to 62929

    Re: Can't update H1 tags in config files

    StevenLockey,
     
    I suggest you create your own HTML filter and replace all <h1> tags to <h1 style=..>.
     
     
    Hope it helps.
     
    Let me know if you have any further questions.
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-04-2010, 4:43 AM 63062 in reply to 63018

    Re: Can't update H1 tags in config files

    Sorry I'm a bit confused, where does this bit of JS go? On the page with the editor on I'd guess?
    Your help pages often give useful sections of code but then no real advice on where they need to be placed for people who aren't as familiar with your product. Please give full information in this sort of documentation, thanks.
  •  08-04-2010, 9:04 AM 63072 in reply to 63062

    Re: Can't update H1 tags in config files

    Creates your own HTML Filter


    The following code shows how to create your own HTML Filter to remove any tag you don't want. In this example, all form tags will be removed automatically. All you need to do is adding the code below into the bottom of the page.

     

    1. <script type="text/javascript">      
    2. function CuteEditor_FilterHTML(editor,code)   
    3. {   
    4.     return code.replace(/(<form[^\>]*\>)([\s\S]*)(\<\/form\>)/i, "$2");   
    5. }   
    6. function CuteEditor_FilterCode(editor,code)   
    7. {   
    8.     return code.replace(/(<form[^\>]*\>)([\s\S]*)(\<\/form\>)/i, "$2");   
    9. }   
    10. </script>  

     


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-05-2010, 8:16 AM 63122 in reply to 63072

    Re: Can't update H1 tags in config files

    Hi, added this code:
     
     
       <script type="text/javascript">      
            function CuteEditor_FilterHTML(editor,code)   
            {   
                return code.replace(/(<h1[^\>]*\>)([\s\S]*)(\<\/h1\>)/i, "<h1 style="padding:0;margin:0">$2</h1>");   
            }   
            function CuteEditor_FilterCode(editor,code)   
            {   
                return code.replace(/(<h1[^\>]*\>)([\s\S]*)(\<\/h1\>)/i, "<h1 style="padding:0;margin:0">$2</h1>");   
            }   
            </script> 
    To the pages containing our editor.
    I then inserted a h1 tag via the drop-down in the wyswig. 
    There was no style code added, in fact the code was not changed at all including after saving the page and checking it on the live site and in the editor again. The editor did not function any differently then it had been functioning previously. 
     
    I have to assume that I've made the modifications to work on the h1 tags correctly as it didn't supply much information on how to make the modifications.
     
     
  •  08-06-2010, 12:48 AM 63155 in reply to 63122

    Re: Can't update H1 tags in config files

    StevenLockey:
    Hi, added this code:
     
     
       <script type="text/javascript">      
            function CuteEditor_FilterHTML(editor,code)   
            {   
                return code.replace(/(<h1[^\>]*\>)([\s\S]*)(\<\/h1\>)/i, "<h1 style="padding:0;margin:0">$2</h1>");   
            }   
            function CuteEditor_FilterCode(editor,code)   
            {   
                return code.replace(/(<h1[^\>]*\>)([\s\S]*)(\<\/h1\>)/i, "<h1 style="padding:0;margin:0">$2</h1>");   
            }   
            </script> 
    To the pages containing our editor.
    I then inserted a h1 tag via the drop-down in the wyswig. 
    There was no style code added, in fact the code was not changed at all including after saving the page and checking it on the live site and in the editor again. The editor did not function any differently then it had been functioning previously. 
     
    I have to assume that I've made the modifications to work on the h1 tags correctly as it didn't supply much information on how to make the modifications.
     
     
     
    Hi StevenLockey,
     
    Try
     
      <script type="text/javascript">     
            function CuteEditor_FilterHTML(editor,code)  
            {  
                return code.split("<h1>").join("<h1 style='padding:0;margin:0'>");
            }  
            function CuteEditor_FilterCode(editor,code)  
            {  
               return code.split("<h1>").join("<h1 style='padding:0;margin:0'>");
            }  
            </script>
     
    Regards,
     
    Ken
  •  08-06-2010, 4:57 AM 63163 in reply to 63155

    Re: Can't update H1 tags in config files

    Hi, That worked great for a single heading, I really need to do this for all headings except h1s, so I changed it to this:
     
    <script type="text/javascript">     
                   function CuteEditor_FilterHTML(editor,code)  
                   {  
                       return code.split("<h3>").join("<h3 style='padding:0;margin:0'>");
                   }  
                   function CuteEditor_FilterCode(editor,code)  
                   {  
                      return code.split("<h3>").join("<h3 style='padding:0;margin:0'>");
                   }  
                   function CuteEditor_FilterHTML(editor,code)  
                   {  
                      return code.split("<h2>").join("<h2 style='padding:0;margin:0'>");
                   }  
                   function CuteEditor_FilterCode(editor,code)  
                   {  
                      return code.split("<h2>").join("<h2 style='padding:0;margin:0'>");
            } 
                   function CuteEditor_FilterHTML(editor,code)  
                   {  
                      return code.split("<h4>").join("<h4 style='padding:0;margin:0'>");
                   }  
                   function CuteEditor_FilterCode(editor,code)  
                   {  
                      return code.split("<h4>").join("<h4 style='padding:0;margin:0'>");
                   }
                   function CuteEditor_FilterHTML(editor,code)  
                   {  
                       return code.split("<h5>").join("<h5 style='padding:0;margin:0'>");
                   }  
                   function CuteEditor_FilterCode(editor,code)  
                   {  
                       return code.split("<h5>").join("<h5 style='padding:0;margin:0'>");
                   }  
           </script>
     
    Unfortunatly this only picks up the first heading tag in the list and ignore the others, I also tried doing multiple headings in the same function which was never going to work since you can only return once for each function :)
     
    How would I write this to allow me to do multiple headings?
  •  08-09-2010, 6:29 AM 63251 in reply to 63163

    Re: Can't update H1 tags in config files

    Quick bump since this has been hanging around a few days now.
  •  08-11-2010, 8:49 PM 63345 in reply to 63251

    Re: Can't update H1 tags in config files

    Please try the following code:
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
    <head>
    </head>
    <body>
        <form id="Form1" runat="server">
        <CE:Editor ID="Editor1" EditorWysiwygModeCss="../example.css" ThemeType="Office2007"
            EditCompleteDocument="true" AllowPasteHtml="false" runat="server">
        </CE:Editor>
        <br>
        <asp:Button ID="btnUpdate" OnClick="Submit" runat="server" Text="Submit"></asp:Button><br />
        <asp:TextBox ID="textbox1" runat="server" TextMode="MultiLine" Height="250px" Width="750px"
            Font-Name="Arial"></asp:TextBox>
        </form>
    </body>
    </html>
    <script runat="server">
      
        void Page_Load(object sender, System.EventArgs e)
        {
            if (IsPostBack)
            {
                Editor1.SaveFile("document.htm");
                textbox1.Text = Editor1.Text;
            }
            else
            {
                Editor1.Text = "123";
            }
        }
        public void Submit(object sender, System.EventArgs e)
        {
            Editor1.SaveFile("document.htm");
            textbox1.Text = Editor1.Text;
        }
    </script>
    <script type="text/javascript">
        function CuteEditor_FilterHTML(editor, code) {
            test1 = code.split("<h1>").join("<h1 style='color:red;padding:0;margin:0'>");
            test2 = test1.split("<h2>").join("<h2 style='color:red;padding:0;margin:0'>");
            test3 = test2.split("<h3>").join("<h3 style='color:red;padding:0;margin:0'>");
            test4 = test3.split("<h4>").join("<h4 style='color:red;padding:0;margin:0'>");
            return test4;
        }
        function CuteEditor_FilterCode(editor, code) {
            test1 = code.split("<h1>").join("<h1 style='color:red;padding:0;margin:0'>");
            test2 = test1.split("<h2>").join("<h2 style='color:red;padding:0;margin:0'>");
            test3 = test2.split("<h3>").join("<h3 style='color:red;padding:0;margin:0'>");
            test4 = test3.split("<h4>").join("<h4 style='color:red;padding:0;margin:0'>");
            return test4;
        }      
     </script>
    Regards,
    Eric

     

  •  09-03-2010, 10:00 AM 63834 in reply to 63345

    Re: Can't update H1 tags in config files

    Works beautifully, thanks
View as RSS news feed in XML