({
node,
inline,
className: codeClassName,
children,
style,
...props
})
| 165 | return <ol>{children}</ol>; |
| 166 | }, |
| 167 | code({ |
| 168 | node, |
| 169 | inline, |
| 170 | className: codeClassName, |
| 171 | children, |
| 172 | style, |
| 173 | ...props |
| 174 | }) { |
| 175 | const match = /language-(\w+)/.exec(codeClassName || ''); |
| 176 | const language = match?.[1]; |
| 177 | const Wrapper = language ? SyntaxHighlighterAsync : SyntaxHighlighter; |
| 178 | if (language) { |
| 179 | loadLanguages(); |
| 180 | } |
| 181 | |
| 182 | return ( |
| 183 | <> |
| 184 | {!inline && ( |
| 185 | <div className="flex h-10 items-center justify-between bg-surface-float px-3"> |
| 186 | <Typography |
| 187 | type={TypographyType.Callout} |
| 188 | bold |
| 189 | color={TypographyColor.Secondary} |
| 190 | tag={TypographyTag.Span} |
| 191 | className="inline leading-8" |
| 192 | > |
| 193 | {language || 'Code snippets'} |
| 194 | </Typography> |
| 195 | <div className="flex gap-2"> |
| 196 | <Button |
| 197 | variant={ButtonVariant.Tertiary} |
| 198 | icon={<CopyIcon />} |
| 199 | disabled={copying || isLoading} |
| 200 | size={ButtonSize.Small} |
| 201 | onClick={() => { |
| 202 | if (onCopy) { |
| 203 | onCopy(); |
| 204 | } |
| 205 | copy({ |
| 206 | textToCopy: String(children), |
| 207 | }); |
| 208 | }} |
| 209 | /> |
| 210 | {header?.buttons ? header.buttons : null} |
| 211 | </div> |
| 212 | </div> |
| 213 | )} |
| 214 | |
| 215 | {!inline ? ( |
| 216 | <div |
| 217 | className={classNames( |
| 218 | 'px-5 py-3', |
| 219 | isExpanded || !isExpandable |
| 220 | ? undefined |
| 221 | : 'max-h-[8.4375rem]', |
| 222 | )} |
| 223 | ref={(element) => { |
| 224 | if (isExpandable && element && !canExpand) { |
nothing calls this directly
no test coverage detected