import { useBlockProps as blockProps, RichText } from '@wordpress/block-editor'; import { type BlockConfiguration, createBlock, registerBlockType, } from '@wordpress/blocks'; import metadata from './block.json' with { type: 'json' }; import './style.css'; import { __ } from '@wordpress/i18n'; import { Editor } from './Editor.tsx'; import { makeFitToWidth } from './helpers.ts'; import { icon } from './icon.tsx'; export type Attributes = { content: string; margin?: string; lineHeight?: string; maxFontSize?: string | number; baseFontSize?: string | number; }; registerBlockType(metadata as BlockConfiguration, { icon, category: 'text', edit: ({ attributes, setAttributes }) => ( ), save: ({ attributes }) => { if (!attributes.content) return null; return (
); }, transforms: { from: [ { type: 'block', blocks: ['core/paragraph'], transform: (attrs) => createBlock(metadata.name, attrs), }, ], to: [ { type: 'block', blocks: ['core/paragraph'], transform: (attrs) => createBlock('core/paragraph', attrs), }, ], }, example: { attributes: { lineHeight: '1.2', // translators: Line breaks are language specific. Check the block preview in the editor. content: __( "So, get away
Another way to feel what you didn't
want yourself to know
And let yourself go
You know you didn't lose your self-control
Let's start at the rainbow
Turn away
Another way to be
where you didn't want yourself to go
Let yourself go
Is that a compromise", 'fit-to-width', ), }, }, });