Copy link to clipboard
Copied
Hi All,
I've one doubt on the indesign javascript the current selection to select next paragraphs of same paragraph style or particular paragraphstyle till the selection to be adding.
there is a condtion if (title or en) paragarph style come stop the selection.
Like the below snapshot.
Input
output
like getPreviousPara() concept.
getPreviousPara()
I tested someone code code but I can't get the solution could you anyone help me.
found = app.selection[0];
st = found.parentStory;
pCurr = found.paragraphs[0];
ipNext = st.insertionPoints[ pCurr.insertionPoints[-1].index ];
var pNext = ipNext.paragraphs[0];
alert(pNext.contents);
Regards,
csm
Try this:
var nextPara = app.selection[0].parentStory.paragraphs.nextItem(app.selection[0].paragraphs[-1]);
/*Loop: If next paragraph is NOT "title" or "en" paragraph style,
add it to the current selection. */
try{
while(nextPara.appliedParagraphStyle != app.activeDocument.paragraphStyles.item("title")
&& nextPara.appliedParagraphStyle != app.activeDocument.paragraphStyles.item("en"))
{
nextPara.select(SelectionOptions.addTo);
nex
...
Copy link to clipboard
Copied
Try this:
var nextPara = app.selection[0].parentStory.paragraphs.nextItem(app.selection[0].paragraphs[-1]);
/*Loop: If next paragraph is NOT "title" or "en" paragraph style,
add it to the current selection. */
try{
while(nextPara.appliedParagraphStyle != app.activeDocument.paragraphStyles.item("title")
&& nextPara.appliedParagraphStyle != app.activeDocument.paragraphStyles.item("en"))
{
nextPara.select(SelectionOptions.addTo);
nextPara = app.selection[0].parentStory.paragraphs.nextItem(app.selection[0].paragraphs[-1]);
}
}
catch(err) {
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Robert at ID-Tasker Updated, thanks!
Copy link to clipboard
Copied
@danaken3 works perfect!
But I seen one post in same ID Scirpting forum if we used the nextItem() the performance getting slow, in more stories and more pages.
Thank for your support!
Copy link to clipboard
Copied
Unfortunately, that's the price you've to pay for using next/prev.
Do you need to do it once - globally - or many times - selectively?
On the same Story - multiple Stories?