| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import stripAnsi from 'strip-ansi'; |
| 3 |
import { Attributes } from '../types'; |
| 4 |
|
| 5 |
export const CopyButton = ({ attributes }: { attributes: Attributes }) => ( |
| 6 |
<span |
| 7 |
// Using a span to prevent aggressive button styling from themes |
| 8 |
role="button" |
| 9 |
tabIndex={0} |
| 10 |
data-code={stripAnsi(attributes.code ?? '')} |
| 11 |
style={{ color: attributes?.textColor ?? 'inherit', display: 'none' }} |
| 12 |
aria-label={__('Copy', 'code-block-pro')} |
| 13 |
className="code-block-pro-copy-button"> |
| 14 |
<svg |
| 15 |
xmlns="http://www.w3.org/2000/svg" |
| 16 |
style={{ width: 24, height: 24 }} |
| 17 |
fill="none" |
| 18 |
viewBox="0 0 24 24" |
| 19 |
stroke="currentColor" |
| 20 |
strokeWidth="2"> |
| 21 |
<path |
| 22 |
className="with-check" |
| 23 |
strokeLinecap="round" |
| 24 |
strokeLinejoin="round" |
| 25 |
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" |
| 26 |
/> |
| 27 |
<path |
| 28 |
className="without-check" |
| 29 |
strokeLinecap="round" |
| 30 |
strokeLinejoin="round" |
| 31 |
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" |
| 32 |
/> |
| 33 |
</svg> |
| 34 |
</span> |
| 35 |
); |
| 36 |
|