Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
For more clarification kindly look at given below link :-
http://dl.dropbox.com/u/4847331/MyStuff/storyEditor_grab.bmp
Mac
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now