summary block: tweak name, and attrs handling

This commit is contained in:
Damián Suárez 2023-12-01 09:14:11 -03:00
parent 874bffc0db
commit 8cf5424c5e
3 changed files with 17 additions and 22 deletions

View File

@ -37,7 +37,8 @@
"type": "string"
},
"helpText": {
"type": "string"
"type": "string",
"default": "Summarize this product in 1-2 short sentences. We'll show it at the top of the page."
},
"content": {
"type": "string",

View File

@ -26,7 +26,7 @@ import { SummaryAttributes } from './types';
import { ALIGNMENT_CONTROLS } from './constants';
import { ProductEditorBlockEditProps } from '../../../types';
export function Edit( {
export function SummaryBlockEdit( {
attributes,
setAttributes,
context,
@ -36,7 +36,7 @@ export function Edit( {
style: { direction },
} );
const contentId = useInstanceId(
Edit,
SummaryBlockEdit,
'wp-block-woocommerce-product-summary-field__content'
);
const [ summary, setSummary ] = useEntityProp< string >(
@ -88,24 +88,18 @@ export function Edit( {
<BaseControl
id={ contentId.toString() }
label={ createInterpolateElement(
label || __( 'Summary', 'woocommerce' ),
{
optional: (
<span className="woocommerce-product-form__optional-input">
{ __( '(OPTIONAL)', 'woocommerce' ) }
</span>
),
}
) }
help={
typeof helpText === 'string'
? helpText
: __(
"Summarize this product in 1-2 short sentences. We'll show it at the top of the page.",
'woocommerce'
)
label={
label
? createInterpolateElement( label, {
optional: (
<span className="woocommerce-product-form__optional-input">
{ __( '(OPTIONAL)', 'woocommerce' ) }
</span>
),
} )
: null
}
help={ helpText }
>
<div { ...blockProps }>
<RichText

View File

@ -2,7 +2,7 @@
* Internal dependencies
*/
import blockConfiguration from './block.json';
import { Edit } from './edit';
import { SummaryBlockEdit } from './edit';
import { registerProductEditorBlockType } from '../../../utils';
const { name, ...metadata } = blockConfiguration;
@ -11,7 +11,7 @@ export { name, metadata };
export const settings = {
example: {},
edit: Edit,
edit: SummaryBlockEdit,
};
export function init() {