Asu Posted April 4, 2021 Posted April 4, 2021 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.
comment Posted April 4, 2021 Posted April 4, 2021 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
Recommended Posts
This topic is 1340 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now