| 127 | const CodeBlock = ({ children, onClickExecute, codeBlockMaxWidthAtom }: CodeBlockProps) => { |
| 128 | const codeBlockMaxWidth = useAtomValueSafe(codeBlockMaxWidthAtom); |
| 129 | const getLanguage = (children: any): string => { |
| 130 | if (children?.props?.className) { |
| 131 | const match = children.props.className.match(/language-([\w+-]+)/i); |
| 132 | if (match) return match[1]; |
| 133 | } |
| 134 | return "text"; |
| 135 | }; |
| 136 | |
| 137 | const handleCopy = async (e: React.MouseEvent) => { |
| 138 | const textToCopy = extractText(children).replace(/\n$/, ""); |