我正在尝试在古腾堡(Gutenberg)使用HOC withInstanceId
(以生成唯一的标识符以用作HTML中的ID)和withColors
(以在边栏中使用颜色选择器),并我不确定正确的Esnext语法。 (而且我从技术上讲应该是正确的非Esnext语法...)
这是我的出发点,但这显然是不正确的:
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { withColors } = wp.editor;
const { withInstanceId } = wp.compose;
registerBlockType( 'blocksetc/test',{
title: __( 'title' ),attributes: {
highlightColor: {
type: "string"
},},edit: withColors( 'highlightColor' )( function ({ attributes,setattributes,classname,instanceId }) {
return (
);
},save( { attributes } ) {
return (
);
},} );
需要一些指导。