Closed
Description
opened on Feb 25, 2019
I'm adding a custom button to the formatting toolbar using the format API
( function( wp ) {
var MyCustomButton = function( props ) {
return wp.element.createElement(
wp.editor.RichTextToolbarButton, {
icon: 'editor-code',
title: 'Sample output',
onClick: function() {
props.onChange( wp.richText.toggleFormat(
props.value,
{ type: 'my-custom-format/sample-output' }
) );
},
isActive: props.isActive,
}
);
}
wp.richText.registerFormatType(
'my-custom-format/sample-output', {
title: 'Sample output',
tagName: 'sample',
className: null,
edit: MyCustomButton,
}
);
} )( window.wp );
The new custom button is added to the formatting toolbar of all the blocks. Is it possible to register it to a specific block only or a list of blocks?
Activity