Skip to main content
Inspiring
April 30, 2010
Answered

Get Selected Paragraphs

  • April 30, 2010
  • 1 reply
  • 412 views

Hi,

How can I get an array (or a reference) to the selected paragraphs? I tried a "ElementRange" that is updated every time the SelectionState changes, but it only has a reference to the first and last paragraphs.

Any ideas?

tks.

This topic has been closed for replies.
Correct answer robin_briggs

I haven't checked this, but it seems like something like this should work:

paragraphArray:Array = [];

var range:ElementRange = ElementRange.createElementRange(textFlow, absoluteStart,absoluteEnd);

var lastParagraph:ParagraphElement = range.lastParagraph;

for (var leaf:FlowLeafElement = range.firstLeaf;  leaf != null; leaf = leaf.getNextLeaf(lastParagraph))
{
     var paragraph:ParagraphElement = leaf.getParagraph();
     paragraphArray.push(paragraph);     // or just do something with the paragraph here
}
return paragraphArray;
- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
April 30, 2010

I haven't checked this, but it seems like something like this should work:

paragraphArray:Array = [];

var range:ElementRange = ElementRange.createElementRange(textFlow, absoluteStart,absoluteEnd);

var lastParagraph:ParagraphElement = range.lastParagraph;

for (var leaf:FlowLeafElement = range.firstLeaf;  leaf != null; leaf = leaf.getNextLeaf(lastParagraph))
{
     var paragraph:ParagraphElement = leaf.getParagraph();
     paragraphArray.push(paragraph);     // or just do something with the paragraph here
}
return paragraphArray;
- robin

oscar7878Author
Inspiring
April 30, 2010

Thanks Robin! works just perfect.