HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/bwcdev/wp-content/plugins/quiz-master-next/blocks/src/answer-option/index.js
import { registerBlockType } from '@wordpress/blocks';
import Edit from './edit';
import metadata from './block.json';
import { answerOptionBlockIcon } from "../component/icon";

registerBlockType( metadata.name, {
	icon: answerOptionBlockIcon,
	__experimentalLabel( attributes, { context } ) {
		const { content } = attributes;

		const customName = attributes?.metadata?.name;
		const hasContent = content?.length > 0;

		// In the list view, use the answer content as the label.
		// If the content is empty, fall back to the default label.
		if ( context === 'list-view' && ( customName || hasContent ) ) {
			return customName || content;
		}
	},
	merge( attributes, attributesToMerge ) {
		return {
			content:
				( attributes.content || '' ) +
				( attributesToMerge.content || '' ),
		};
	},
	edit: Edit,
} );