2 Replies Latest reply on May 10, 2010 10:32 PM by Shonkyin

    How to add one more character in selection [JS] [CS2]

    Mac_06 Level 2

      Hi All

      I am wondering the way to add one more character in my selection.

      I have a script which adds the xml Element and parent xml Element in selected text so far so good, but further my expectation is to cut this text with tag and paste it into anchored frame but in selection it won’t add the closing tag of parent tag.

       

      function add_element(mySel){
      var the_add_tag = the_document.xmlElements.item(0).xmlElements.add ("story", mySel);
      var add_space = mySel.insertionPoints[0].contents = " "
      var new_selec = app.select(mySel.characters[0], SelectionOptions.addTo);
      var my_new_sel = app.selection[0];
      var add_parent_tag = the_document.xmlElements.item(0).xmlElements.add ("sidenote", my_new_sel);
       app.select(mySel.characters[0], SelectionOptions.replaceWith);
       app.select(mySel.characters[1], SelectionOptions.addTo);
       app.selection[0].remove();
             app.select(my_new_sel.characters[0], SelectionOptions.replaceWith);
             app.select(my_new_sel.characters[-1], SelectionOptions.addTo);
      }
      

       

      Could anyone suggest me the way to achieve it as I am bit primitive in scripting?

      Many Thanks

      Mac