Skip to main content
Known Participant
Mar 6, 2025 12:46 PM UTC
Question

Contents getting selected from Different XMLElements from TextStyleRanges.


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?

11 replies

Robert at ID-Tasker
Legend
Mar 6, 2025 9:24 PM UTC

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

 

Translate
Known Participant
Mar 7, 2025 4:58 AM UTC

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

 

Translate
Robert at ID-Tasker
Legend
Mar 7, 2025 10:21 AM UTC

Because TextStyleRange isn't split by XMLElements. 

 

Translate