1 Rich Text Editor & 1 Image selector

Last post 12-04-2013, 8:12 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-04-2013, 1:46 AM 78498

    1 Rich Text Editor & 1 Image selector

    Hi,


    I am wondering if it is possible to have 1 full rich text editor and 1 image selector on a page.

     

    The current example shows the image selector button but breaks as soon as you put another editor on the page.


    Thanks in advance. 

  •  12-04-2013, 8:12 AM 78503 in reply to 78498

    Re: 1 Rich Text Editor & 1 Image selector

    Hi gim-matt,

     

    Yes, please try the example below, I added two editors in it. one is the normal editor, another ues for image selector.

     

    1. <%@ Page Language="c#" %>  
    2.   
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>  
    4.   
    5. <script runat="server">  
    6. </script>  
    7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    8. <html xmlns="http://www.w3.org/1999/xhtml">  
    9. <head>  
    10.     <title>RichTextEditor - Editor as image selector</title>  
    11.     <link rel="stylesheet" href="../example.css" type="text/css" />  
    12.     <script type="text/javascript">  
    13.         var editor;  
    14.         var showed = false;  
    15.   
    16.         function ShowEditorGallery() {  
    17.             showed = true;  
    18.             if (editor) {  
    19.                 editor.ExecUICommand(null"InsertGallery");  
    20.             }  
    21.         }  
    22.   
    23.         function RichTextEditor_OnLoad(argeditor) {  
    24.             var config = argeditor._config;  
    25.             if (config.uniqueid == "Editor1") {  
    26.                 config.showtoolbar = false;  
    27.                 config.showtoolbar_code = false;  
    28.                 config.showbottombar = false;  
    29.                 config.preloadplugins = "";  
    30.                 var div = document.getElementById(config.containerid);  
    31.                 div.style.display = "none";  
    32.                 editor = argeditor;  
    33.                 if (showed)  
    34.                     ShowEditorGallery()  
    35.             }  
    36.         }  
    37.   
    38.         function RichTextEditor_OnTextChanged() {  
    39.             if (!showed) return;  
    40.             showed = false;  
    41.             var img = editor.GetPointNode();  
    42.             if (img && img.GetNameLower() == "img") {  
    43.                 var src = img.GetAttribute("src");  
    44.                 OnGetImageUrl(src);  
    45.             }  
    46.             editor.SetText("");  
    47.         }  
    48.         function OnGetImageUrl(src) {  
    49.             document.getElementById("result").innerHTML = "You selected : " + src;  
    50.         }  
    51.   
    52.     </script>  
    53. </head>  
    54. <body>  
    55.     <form id="Form1" method="post" runat="server">  
    56.         <RTE:Editor runat="server" ID="Editor2" />  
    57.         <div style="display: none;">  
    58.             <RTE:Editor runat="server" ID="Editor1" />  
    59.         </div>  
    60.   
    61.         <br />  
    62.         <div>  
    63.             <button type="button" onclick="ShowEditorGallery();return false;">Select Image</button>  
    64.         </div>  
    65.         <br />  
    66.         <div id="result"></div>  
    67.     </form>  
    68. </body>  
    69. </html>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML