Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center

Re: selection to node

  •  01-09-2014, 11:18 PM

    Re: selection to node

    Dear Marvin,

     

    I write a demo with mark

     

    1. if (info.Arguments[1] == "DoMark") {  
    2.     var nodes = editor.ExtractRangeNodes(false);  
    3.     var pointnode = editor.GetPointNode();  
    4.     if (nodes.length == 0) 
    5.        return; 
    6.     var root = pointnode;  
    7.     if (!root.Contains(nodes[0]))  
    8.         root = root.GetParent();  
    9.     if (nodes.length == 1) {  
    10.         //select 1 node  
    11.         if (nodes[0].GetName() == "mark" || (root.GetName() == "mark" && root.GetChildCount() == 1)) {  
    12.             //self is mark node  
    13.             alert(root.GetName() == "mark" ? root.GetAttribute("data-value") : nodes[0].GetAttribute("data-value"));  
    14.         }  
    15.         else {  
    16.             var mark = editor.ParseHtmlCode("<mark data-value=\"1\"></mark>")[0];  
    17.             editor.SurroundNode(mark);  
    18.             editor.Focus();  
    19.         }  
    20.     }  
    21.     else {  
    22.         //select multiple nodes  
    23.         if (root.GetName() == "mark" && root.GetChildCount() <= nodes.length) {  
    24.             //surround with mark node  
    25.             alert(root.GetAttribute("data-value"));  
    26.         }  
    27.         else {  
    28.             var html = editor.ExtractRangeHTML(true);  
    29.             var mark = "<mark data-value=\"2\">" + html + "</mark>";  
    30.             editor.InsertHTML(mark);  
    31.             editor.Focus();  
    32.         }  
    33.     }  
    34. }  
     

     

    Regards,

    Jeff 

View Complete Thread
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.