( node: TextNode, settings: TailwindSettings, )
| 125 | }; |
| 126 | |
| 127 | export const tailwindText = ( |
| 128 | node: TextNode, |
| 129 | settings: TailwindSettings, |
| 130 | ): string => { |
| 131 | const layoutBuilder = new TailwindTextBuilder(node, settings) |
| 132 | .commonPositionStyles() |
| 133 | .textAlignHorizontal() |
| 134 | .textAlignVertical(); |
| 135 | |
| 136 | const styledHtml = layoutBuilder.getTextSegments(node); |
| 137 | previousExecutionCache.push(...styledHtml); |
| 138 | |
| 139 | let content = ""; |
| 140 | if (styledHtml.length === 1) { |
| 141 | const segment = styledHtml[0]; |
| 142 | layoutBuilder.addAttributes(segment.style); |
| 143 | |
| 144 | const getFeatureTag = (features: Record<string, boolean>): string => { |
| 145 | if (features.SUBS === true) return "sub"; |
| 146 | if (features.SUPS === true) return "sup"; |
| 147 | return ""; |
| 148 | }; |
| 149 | |
| 150 | const additionalTag = getFeatureTag(segment.openTypeFeatures); |
| 151 | content = additionalTag |
| 152 | ? `<${additionalTag}>${segment.text}</${additionalTag}>` |
| 153 | : segment.text; |
| 154 | } else { |
| 155 | content = styledHtml |
| 156 | .map((style) => { |
| 157 | const tag = |
| 158 | style.openTypeFeatures.SUBS === true |
| 159 | ? "sub" |
| 160 | : style.openTypeFeatures.SUPS === true |
| 161 | ? "sup" |
| 162 | : "span"; |
| 163 | |
| 164 | return `<${tag} class="${style.style}">${style.text}</${tag}>`; |
| 165 | }) |
| 166 | .join(""); |
| 167 | } |
| 168 | |
| 169 | return `\n<div${layoutBuilder.build()}>${content}</div>`; |
| 170 | }; |
| 171 | |
| 172 | const tailwindFrame = async ( |
| 173 | node: FrameNode | InstanceNode | ComponentNode | ComponentSetNode, |
no test coverage detected