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