Skip to main content
Known Participant
Mar 6, 2025 10:55 AM 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?

3 replies

Legend
Mar 6, 2025 11:12 AM UTC

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.

Translate
Known Participant
Mar 7, 2025 6:17 AM UTC

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

Translate
Known Participant
Mar 7, 2025 6:19 AM UTC

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

Translate