(
itemStl: ItemStyleProps,
txStl: TextStyleProps,
txCfg: ElementTextConfig
)
| 167 | * `styleEmphasis: {textFill: 'red'}` will remove the normal auto added stroke. |
| 168 | */ |
| 169 | export function convertToEC4StyleForCustomSerise( |
| 170 | itemStl: ItemStyleProps, |
| 171 | txStl: TextStyleProps, |
| 172 | txCfg: ElementTextConfig |
| 173 | ): ZRStyleProps { |
| 174 | |
| 175 | const out = itemStl as Dictionary<unknown>; |
| 176 | |
| 177 | // See `custom.ts`, a trick to set extra `textPosition` firstly. |
| 178 | out.textPosition = out.textPosition || txCfg.position || 'inside'; |
| 179 | txCfg.offset != null && (out.textOffset = txCfg.offset); |
| 180 | txCfg.rotation != null && (out.textRotation = txCfg.rotation); |
| 181 | txCfg.distance != null && (out.textDistance = txCfg.distance); |
| 182 | |
| 183 | const isInside = (out.textPosition as string).indexOf('inside') >= 0; |
| 184 | const hostFill = itemStl.fill || tokens.color.neutral99; |
| 185 | |
| 186 | convertToEC4RichItem(out, txStl); |
| 187 | |
| 188 | const textFillNotSet = out.textFill == null; |
| 189 | if (isInside) { |
| 190 | if (textFillNotSet) { |
| 191 | out.textFill = txCfg.insideFill || tokens.color.neutral00; |
| 192 | !out.textStroke && txCfg.insideStroke && (out.textStroke = txCfg.insideStroke); |
| 193 | !out.textStroke && (out.textStroke = hostFill); |
| 194 | out.textStrokeWidth == null && (out.textStrokeWidth = 2); |
| 195 | } |
| 196 | } |
| 197 | else { |
| 198 | if (textFillNotSet) { |
| 199 | out.textFill = itemStl.fill || txCfg.outsideFill || tokens.color.neutral00; |
| 200 | } |
| 201 | !out.textStroke && txCfg.outsideStroke && (out.textStroke = txCfg.outsideStroke); |
| 202 | } |
| 203 | |
| 204 | out.text = txStl.text; |
| 205 | out.rich = txStl.rich; |
| 206 | |
| 207 | each(txStl.rich, function (richItem) { |
| 208 | convertToEC4RichItem(richItem as Dictionary<unknown>, richItem); |
| 209 | }); |
| 210 | |
| 211 | return out; |
| 212 | } |
| 213 | |
| 214 | function convertToEC4RichItem(out: Dictionary<unknown>, richItem: TextStylePropsPart) { |
| 215 | if (!richItem) { |
no test coverage detected
searching dependent graphs…