PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.4.0
Code Block Pro – Beautiful Syntax Highlighting v1.4.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 / front / BlockOutput.tsx

BlockOutput.tsx in Code Block Pro – Beautiful Syntax Highlighting 1.4.0, at src/front/BlockOutput.tsx

40 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { RichText, useBlockProps as blockProps } from '@wordpress/block-editor';
2 import { HeaderType } from '../editor/components/HeaderType';
3 import { Attributes } from '../types';
4 import { CopyButton } from './CopyButton';
5 import './style.css';
6
7 export const BlockOutput = ({ attributes }: { attributes: Attributes }) => (
8 <div
9 {...blockProps.save()}
10 data-code-block-pro-font-family={attributes.fontFamily}
11 style={{
12 fontSize: attributes.fontSize,
13 // Tiny check to avoid block invalidation error
14 fontFamily: attributes.fontFamily
15 ? [
16 attributes.fontFamily,
17 'ui-monospace',
18 'SFMono-Regular',
19 'Menlo',
20 'Monaco',
21 'Consolas',
22 'monospace',
23 ]
24 .filter(Boolean)
25 .join(',')
26 : undefined,
27 lineHeight: attributes.lineHeight,
28 }}>
29 {attributes.code?.length > 0 ? (
30 <>
31 <HeaderType {...attributes} />
32 {attributes.copyButton && (
33 <CopyButton attributes={attributes} />
34 )}
35 <RichText.Content value={attributes.codeHTML} />
36 </>
37 ) : null}
38 </div>
39 );
40