Apply font, size, and color to selected characters in Photoshop UXP

Hello,

I’m developing Brand Manager, an extension that stores reusable brand colors, fonts, styles, and sizes.

In Illustrator, when the user highlights part of a text and clicks a saved value in the panel, the change applies only to the selected characters. I would like to support the same workflow in Photoshop:

  • Highlight characters with the Type Tool.
  • Click a saved font, size, style, or color in the UXP panel.
  • Apply the change only to the highlighted characters.
  • If there is only a text cursor, use the style for the next characters typed.

Applying the style to the entire text layer when not editing text is acceptable.

I tried batchPlay, textStyle, and the Type Tool character options, but Photoshop either affects the entire layer or rejects the command.

Is there a supported way to access the active character range and apply or capture its formatting without losing the selection when the panel is clicked?

A working batchPlay or ActionJSON example would be very helpful.

The attached screenshot shows the intended workflow.

Environment:

  • Photoshop 27.9
  • UXP 9.3
  • macO

Thank you