import { __ } from '@wordpress/i18n'; import { useBlockProps, InspectorControls } from '@wordpress/block-editor'; import { SelectControl, FontSizePicker, TextControl } from '@wordpress/components'; import { useState, useEffect } from 'react'; import './editor.scss'; export default function Edit( { attributes, setAttributes } ) { const { heading, pointsFontSizeLarge, headingFontSizeLarge, listStyleType } = attributes; const fontSizes = [ { name: __( 'Small', 'key-points' ), slug: 'small', size: '12px', }, { name: __( 'Medium', 'key-points' ), slug: 'medium', size: '16px', }, { name: __( 'Large', 'key-points' ), slug: 'large', size: '24px', }, { name: __( 'Extra Large', 'key-points' ), slug: 'x-large', size: '36px', }, ]; const listStyleTypeOptions = [ { label: __( 'Disc', 'lcp' ), value: 'disc' }, { label: __( 'Circle', 'lcp' ), value: 'circle' }, { label: __( 'Square', 'lcp' ), value: 'square' }, { label: __( 'None', 'lcp' ), value: 'none' }, ]; // Static Lorem Ipsum key points (5 unique points) const loremIpsumPoints = [ "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ]; const [keyPoints, setKeyPoints] = useState(loremIpsumPoints); // Set initial key points to the Lorem Ipsum array return ( <> {/* Inspector Controls */} {/* List Style Dropdown */} { setAttributes( { listStyleType: newValue } ); } } /> {/* Heading Input */} setAttributes( { heading: newHeading } ) } /> {/* Font Size Picker for Points */} { if ( typeof newFontSize === 'string' ) { setAttributes( { pointsFontSizeLarge: newFontSize } ); } } } fallbackFontSize={ '16px' } /> {/* Font Size Picker for Heading */} { if ( typeof newFontSize === 'string' ) { setAttributes( { headingFontSizeLarge: newFontSize } ); } } } fallbackFontSize={ '24px' } /> {/* Block Content */}

{ __( 'Key Points – hello from the editor!', 'lcp' ) }

{ heading &&

{ heading }

} {/* Display key points */} { keyPoints && keyPoints.length > 0 && ( )} ); }