Copy link to clipboard
Copied
Just curious if it's possible to script (create and or refer to) paragraph styles, and if so what would be the syntax to apply them to a paragraph in a block of text? Is this or will this be something captured by ScriptListener?
Copy link to clipboard
Copied
I have not done any scripting of paragraph styles but a quick test shows that applying a style is recorded and looks very straightforward. Creating a new style is also recorded but looks like it sets overrides to an existing style so may be a littler tricker to script.
I can find a lot of detail about the paragraph style of a textLayer in the descriptor but not the name of the style. I also don't see a way to determine anything about the styles in a document. Names, current or selected style, that kind of thing.
Not saying it is not possiblle, just nothing from a quick look.
Copy link to clipboard
Copied
Thanks, Mike. These are some of the questions I have and was thinking someone should submit a feature request if those features are not available.
I would like to see:
1. Being able to script a style, and check to see if one of that name all ready exists.
2. Be able to easily dected how many paragraphs are in a text block. I'm sure this can be done, but something like textRefLayer.text.paragraphs.length
3. Then be able to take the paragraph number either drived from the above of other means and assign a style to that paragraph.
This would be so much better than the roundabout ways text is formatted differently in the same text block.
Copy link to clipboard
Copied
I think in Photoshop paragraph marks are really just line break chars. So you could search the textItem contents for line break chars to get the number of paragraphs.
As for the rest, I wouldn't hold my breath.
Copy link to clipboard
Copied
Yea, I know I could break apart a text block by the line breaks, but I wonder how you would secifiy which paragraph to apply a style without some sort of paragraph ID. I haven't looked at the actionDescriptor code yet, as you mentioned, but I'm wondering if the name is some number ID.
Copy link to clipboard
Copied
I would say if anything the new paragraph styles have made scripting text layer harder if you want to do more that what is supported in the Object Model. It looks like there isn't a paragraph ID. It looks like it is using a start and end char range. So now we have to deal with paragraph ranges in addition to text ranges.
Copy link to clipboard
Copied
Oh, that's not good!