Skip to main content
Known Participant
March 6, 2025
Question

Contents getting selected from Different XMLElements from TextStyleRanges.

  • March 6, 2025
  • 1 reply
  • 590 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

Robert at ID-Tasker
Legend
March 6, 2025

But in your screenshot - you've selected all 3x Paragraphs? 

 

Known Participant
March 7, 2025

Yeah, but even when I select the single xmlElement (paragraph), the same result im gettting.

 

Robert at ID-Tasker
Legend
March 7, 2025

Because TextStyleRange isn't split by XMLElements.