wp.blocks.registerBlockType('myblock/new-block', {
title: 'New Element',
icon: 'smiley',
category: 'common',
attributes: {
heading: {type: 'string'},
subheading: {type: 'string'}
},
classes:{
type: 'string'
},
edit: function(props) {
function updateHeading(event) {
props.setAttributes({heading: event.target.value})
}
function updateSubheading(event) {
props.setAttributes({subheading: event.target.value})
}
return wp.element.createElement(
"div",
null,
wp.element.createElement(
"h3",
null,
"New Element"
),
wp.element.createElement("div", null, wp.element.createElement("p", null, "heading")),
wp.element.createElement("input", { type: "text", value: props.attributes.heading, onChange: updateHeading }),
wp.element.createElement("div", null, wp.element.createElement("p", null, "Subheading")),
wp.element.createElement("input", { type: "text", value: props.attributes.subheading, onChange: updateSubheading })
);
},
save: function(props)
{
return React.createElement("div", {
class: "post"
},
React.createElement("h1", {
class: "display-4"
}, props.attributes.heading),
React.createElement("p", {
class: "lead"
}, props.attributes.subheading),
React.createElement("hr", {
class: "my-4"
},),
));
}
})
Я хочу добавить Fragment и InspectorControls для отображения параметров класса с правой стороны. В раскрывающемся списке
должна быть опция classOne, classTwo, classThree.
Я новичок в разработке плагинов. Пожалуйста помоги.