PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.18.0
Code Block Pro – Beautiful Syntax Highlighting v1.18.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / src / editor / components / buttons / CopyButton.tsx

CopyButton.tsx in Code Block Pro – Beautiful Syntax Highlighting 1.18.0, at src/editor/components/buttons/CopyButton.tsx

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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-encoded={attributes.useDecodeURI ? true : undefined}
11 data-code={stripAnsi(
12 attributes.useDecodeURI
13 ? // Encode again otherwise WP will decode it
14 encodeURIComponent(attributes.code ?? '')
15 : attributes.code ?? '',
16 )}
17 style={{ color: attributes?.textColor ?? 'inherit', display: 'none' }}
18 aria-label={__('Copy', 'code-block-pro')}
19 className="code-block-pro-copy-button">
20 <svg
21 xmlns="http://www.w3.org/2000/svg"
22 style={{ width: 24, height: 24 }}
23 fill="none"
24 viewBox="0 0 24 24"
25 stroke="currentColor"
26 strokeWidth="2">
27 <path
28 className="with-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 2m-6 9l2 2 4-4"
32 />
33 <path
34 className="without-check"
35 strokeLinecap="round"
36 strokeLinejoin="round"
37 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"
38 />
39 </svg>
40 </span>
41 );
42