Find & Replace feature

Last post 05-16-2011, 9:37 PM by yuenli. 6 replies.
Sort Posts: Previous Next
  •  05-13-2011, 3:24 AM 67560

    Find & Replace feature

    Hi, I would like to check if I can make use of "Find & Replace" feature programmatically from my ASP.NET C# code behind?
     
    We are currently storing the HTML data into our database, and we would like to support Find & Replace from the system backend instead of through the Editor front-end, one of the way we tried is to use editor.PlainText to do the manual search & replace by using Regex, however, I have no way to assgin the PlainText in order to get back the underlying HTML to store back into the DB.
     
    I am amazed by the "Find & Replace" function that found in the editor, would be very happy if this function is being exposed in the dll for us to make use of it.
     
    Please let me know, appreciate your help.
    Thank you.
     
    - Yuen Li 
  •  05-16-2011, 12:06 AM 67578 in reply to 67560

    Re: Find & Replace feature

    Hi yuenli,
     
    Please refer to http://cutesoft.net/developer+guide/scr/Creates-your-own-HTML-Filter.htm
     
    You can achieve the replace function by the html filter.
     
    Regards,
     
    ken
  •  05-16-2011, 2:44 AM 67581 in reply to 67578

    Re: Find & Replace feature

    1. Hi Ken,

    2. May I know what is code here? is it referring to editor.text (which is the underlying HTML)?

    1. Next, I would like to clarify my question here, I would like to be able to do search & replace like the one found in the cute editor toolbar, the search & replace should work from the normal text while the underlying HTML remains.

    1. Please advice.

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

    12. Regards,

    13. Yuen Li

  •  05-16-2011, 3:59 AM 67582 in reply to 67581

    Re: Find & Replace feature

    Hi yuenli,
     
    Myabe the example below can shows you how it work and what it does.
     
    Try create a page by the code below. and than type some content in editor. the script code will replace all "test" to "my new content".
     
    Note: this method will detect all html code.
     
    <%@ Page Language="C#" %>

    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CE:Editor ID="editor1" runat="server">
                </CE:Editor>
            </div>
        </form>
    </body>
    </html>

    <script type="text/javascript">      
    function CuteEditor_FilterHTML(editor,code)   
    {   
         return code.split("test").join("my new content");   
    }   
    function CuteEditor_FilterCode(editor,code)   
    {   
         return code.split("test").join("my new content");   
    }   
    </script>
     
     
    Regards,
     
    Ken
  •  05-16-2011, 9:45 AM 67586 in reply to 67582

    Re: Find & Replace feature

    Hi Ken,
     
    This script code does not apply to text with style. For example, if i apply bold on 'es', the HTML display will look something like this 
    <div>t<strong>es</strong>t</div> 
     
    Replace script code does not apply to this example.
     
    May I know how to apply find & replace on text which have different styling effect? Thanks. 
     
    Regards,
    Yuen Li 
  •  05-16-2011, 8:34 PM 67588 in reply to 67586

    Re: Find & Replace feature

    Hi yuenli,
     
    For now does support this by behind code. Sorry for your inconvenience.
     
    Regards,
     
    Ken
  •  05-16-2011, 9:37 PM 67589 in reply to 67588

    Re: Find & Replace feature

    Hi Ken,
     
    Is the  "Find and Replace" function exposed for us to make use?
    It works perfectly as what we are expected it to be, if there is no method exposed for this purpose, please advice how we can achieve this?
     
    e.g. I type "sleep" in Normal mode and highlight "leep" to red color
    when i apply the "Find and replace", to replace "sleep" to "ABC", it becomes "ABC in black"
     
    How to do the replace function from the normal mode where we can still get the HTML content?
    Please advice. 
     
View as RSS news feed in XML