April 4, 20214 yr Hello - Im looking for solution to this problem: If [text style of selection = X ] then A else B. There does not seem to be an obvious way to get text style of selection. So I tried this workaround: If ( TextStyleAdd ( Middle ( Get ( ActiveFieldContents ) ; Get ( ActiveSelectionStart ) ; Get ( ActiveSelectionSize ) ) ; HighlightYellow ) ; "1"; "0") thinking that if the selection is styled as in the TextStyleAdd expression then it would evaluate as TRUE but it doesn't work. Is there any way? Thanks.
April 4, 20214 yr 21 minutes ago, Asu said: There does not seem to be an obvious way to get text style of selection. This is a trick question, because a selection can have multiple styles, and each substring within the selection can have a different combination of styles. The two functions that can provide the answer are GetAsCSS() and GetAsSVG(). Both return the input text split into SPAN elements according to the style/s applied to each substring. If any substring of text is formatted as HighlightYellow, then both GetAsCSS ( text ) and GetAsSVG ( text ) will contain the pattern: background-color: #FFFF00; See also: https://www.briandunning.com/cf/1611
Create an account or sign in to comment