| 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 |
|