| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { __ } from '@wordpress/i18n'; |
| 2 | +import stripAnsi from 'strip-ansi'; | |
| 2 | 3 | import { Attributes } from '../types'; |
| 3 | 4 | |
| 4 | 5 | export const CopyButton = ({ attributes }: { attributes: Attributes }) => ( |
| 5 | 6 | <span |
| @@ -5,9 +6,9 @@ | ||
| 5 | 6 | <span |
| 6 | 7 | // Using a span to prevent aggressive button styling from themes |
| 7 | 8 | role="button" |
| 8 | 9 | tabIndex={0} |
| 9 | - data-code={attributes.code} | |
| 10 | + data-code={stripAnsi(attributes.code ?? '')} | |
| 10 | 11 | style={{ color: attributes?.textColor ?? 'inherit', display: 'none' }} |
| 11 | 12 | aria-label={__('Copy', 'code-block-pro')} |
| 12 | 13 | className="code-block-pro-copy-button"> |
| 13 | 14 | <svg |