Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
May 10, 2010 May 10, 2010

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

TOPICS
Scripting
866
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 10, 2010 May 10, 2010

For more clarification kindly look at given below link :-

http://dl.dropbox.com/u/4847331/MyStuff/storyEditor_grab.bmp

Mac

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 10, 2010 May 10, 2010
LATEST

Hi Mac,

Here is working code for CS4. Hope it will work on CS2 too.

function add_element(mySel){
var the_add_tag = the_document.xmlElements.item(0).xmlElements.add ("story", mySel);
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(my_new_sel.characters[0], SelectionOptions.ADD_TO);
}

Regards,

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines