/** * External dependencies */ import { isEmpty } from 'lodash' /** * WordPress dependencies */ import { __ } from '@wordpress/i18n' import { Fragment } from '@wordpress/element' import { Button, Dashicon } from '@wordpress/components' import { BlockControls, AlignmentToolbar, useBlockProps } from '@wordpress/block-editor' /** * Internal dependencies */ import getLink from '@helpers/getLink' import Inspector from './components/Inspector' import Question from './components/Question' import generateId from '@helpers/generateId' /** * Render Quetion component. * * @param {Object} props Block attributes * * @return {Array} Array of question editor. */ const renderQuestions = ( props ) => { const { sizeSlug, titleWrapper, titleCssClasses, contentCssClasses, } = props.attributes let { questions } = props.attributes if ( isEmpty( questions ) ) { questions = [ { id: generateId( 'faq-question' ), title: '', content: '', visible: true, }, ] props.setAttributes( { questions } ) } return questions.map( ( question, index ) => { return (