PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.5.0
Code Block Pro – Beautiful Syntax Highlighting v1.5.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.5.0, at src/front/BlockOutput.tsx

32 lines 1.2 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 { fontFamilyLong, maybeClamp } from '../util/fonts';
5 import { CopyButton } from './CopyButton';
6 import './style.css';
7
8 export const BlockOutput = ({ attributes }: { attributes: Attributes }) => (
9 <div
10 {...blockProps.save()}
11 data-code-block-pro-font-family={attributes.fontFamily}
12 style={{
13 fontSize: maybeClamp(attributes.fontSize, attributes.clampFonts),
14 // Tiny check to avoid block invalidation error
15 fontFamily: fontFamilyLong(attributes.fontFamily),
16 lineHeight: maybeClamp(
17 attributes.lineHeight,
18 attributes.clampFonts,
19 ),
20 }}>
21 {attributes.code?.length > 0 ? (
22 <>
23 <HeaderType {...attributes} />
24 {attributes.copyButton && (
25 <CopyButton attributes={attributes} />
26 )}
27 <RichText.Content value={attributes.codeHTML} />
28 </>
29 ) : null}
30 </div>
31 );
32