Skip to main content
Known Participant
March 6, 2025
Question

Contents getting selected from Different XMLElements from TextStyleRanges.

  • March 6, 2025
  • 1 reply
  • 285 views

I have created 3 xmlElements inside the story. All three have same paragraph style.

// Just a dummy script for demo.
if (app.selection.length > 0) {
    // Get the selected item
    var selectedItem = app.selection[0];
    var test = 0;
...
}

 

 

 

In debugger, 

selectedItem.textStyleRanges.length

1
selectedItem.textStyleRanges[0].contents
paragraph 1
paragraph 2
paragraph 3
What I want is since I selected 1st tag(1st xmlElement with content paragraph 1) only that should have displayed on debug console.
I need all the different style ranges  and contents from perticular xmlElement and not the contents from neighbouring xmlElements I know textStyleRanges returns that. But  is there a way to do what I want?

1 reply

Legend
March 6, 2025

Hi,

 

It looks like your three paragraphs are the same stylerange. I am not familiar with the XML structure, but, maybe you should be looking at that.

 

P.

Known Participant
March 7, 2025

What I want is from the Perticular xmlElement say tag1 (has content paragraph1), Is there a way for me to get all textStyleRanges for that alone? Right now with current approach If paragraph styles are same

Known Participant
March 7, 2025

cont... from tag1 only im getting all three paragraphs, Its causing issue for the main task that we are doing.