import { createElement, useMemo } from '@wordpress/element'
import { __ } from 'ct-i18n'
import { registerBlockType } from '@wordpress/blocks'
import Edit from './Edit'
import metadata from './block.json'
import { getAttributesFromOptions, getOptionsForBlock } from 'blocksy-options'
export const options = getOptionsForBlock('dynamic-data')
export const defaultAttributes = getAttributesFromOptions(options)
registerBlockType('blocksy/dynamic-data', {
...metadata,
title: __('Dynamic Data', 'blocksy'),
description: __('Insert dynamic data anywhere you might want.', 'blocksy'),
attributes: {
...metadata.attributes,
...defaultAttributes,
},
icon: {
src: (
),
},
edit: (props) => ,
save: () => null,
__experimentalLabel: (attributes) => {
if (attributes.field === 'wp:title') {
return __('Dynamic Title', 'blocksy')
}
if (attributes.field === 'wp:excerpt') {
return __('Dynamic Excerpt', 'blocksy')
}
if (attributes.field === 'wp:date') {
return __('Dynamic Post Date', 'blocksy')
}
if (attributes.field === 'wp:comments') {
return __('Dynamic Comments', 'blocksy')
}
if (attributes.field === 'wp:terms') {
return __('Dynamic Terms', 'blocksy')
}
if (attributes.field === 'wp:author') {
return __('Dynamic Author', 'blocksy')
}
if (attributes.field === 'wp:featured_image') {
return __('Dynamic Featured Image', 'blocksy')
}
if (attributes.field === 'wp:author_avatar') {
return __('Dynamic Author Avatar', 'blocksy')
}
if (attributes.field === 'woo:price') {
return __('Dynamic Price', 'blocksy')
}
if (attributes.field === 'woo:stock_status') {
return __('Dynamic Stock Status', 'blocksy')
}
if (attributes.field === 'woo:sku') {
return __('Dynamic SKU', 'blocksy')
}
if (attributes.field === 'woo:rating') {
return __('Dynamic Rating', 'blocksy')
}
return __('Dynamic Data', 'blocksy')
},
})