I tried this, but it still doesn’t work, because it adds “& lt;” instead of “<” in the tags that I want to insert:
( function( wp ) {
var withSelect = wp.data.withSelect;
var ifCondition = wp.compose.ifCondition;
var compose = wp.compose.compose;
var el = wp.richText.create({html: '<span class="testClass">test</span>'});
var MyCustomButton= function( props ) {
return wp.element.createElement(
wp.blockEditor.RichTextToolbarButton, {
icon: 'editor-code',
title: 'test',
onClick: function() {
props.onChange( wp.richText.insert(
props.value,
wp.richText.toHTMLString({value: el}),
) );
},
isActive: props.isActive,
}
);
}
wp.richText.registerFormatType(
'test-plugin/test-output', {
title: 'test',
tagName: 'span',
className: "testClass",
edit: MyCustomButton,
}
);
} )( window.wp );