Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import './style.scss';
const { toggleFormat, registerFormatType } = wp.richText;
const { RichTextToolbarButton } = wp.blockEditor;
const formatName = 'igmoweb/boxed-format';
const formatTitle = 'Boxed';
const BoxedButton = ( { onChange, value, isActive } ) => {
const toggleBoxedFormat = () => {
onChange( toggleFormat(
value,
{
type: formatName,
attributes: {
'data-type': 'box',
},
}
) );
};
return (
<RichTextToolbarButton
icon="archive"
title={ formatTitle }
onClick={ toggleBoxedFormat }
isActive={ isActive }
/>
);
};
registerFormatType( formatName, {
title: formatTitle,
tagName: 'span',
className: 'boxed',
edit: BoxedButton,
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.