Создаю новый кастомный блок списка для гутенберг и получаю ошибку: Uncaught SyntaxError: Unexpected token '<' (at custom-list.js.
Ниже код:
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
registerBlockType('custom-bullets-list/custom-block', {
title: 'Custom List',
icon: 'list-view',
category: 'text',
attributes: {
content: {
type: 'string',
default: '',
},
},
edit: function (props) {
const { attributes, setAttributes } = props;
const onContentChange = (newContent) => {
setAttributes({ content: newContent });
};
const contentArray = attributes.content.split('\n');
const listItems = contentArray.map((item, index) => (
{
name: 'core/paragraph',
attributes: {
content: item,
},
}
));
return (
<ul className="custom-bullets-list">
<InnerBlocks
template={listItems}
templateLock="all"
/>
</ul>
);
},
save: function () {
return (
<ul className="custom-bullets-list">
<InnerBlocks.Content />
</ul>
);
},
});