How to use richText.insert to insert HTML ?
-
Hello, here’s what I tried, but it adds the HTML code as simple text, not as a HTML element:
( function( wp ) { var withSelect = wp.data.withSelect; var ifCondition = wp.compose.ifCondition; var myCustomButton = function( props ) { return wp.element.createElement( wp.blockEditor.RichTextToolbarButton, { icon: 'editor-code', title: 'saws', onClick: function() { props.onChange( wp.richText.insert( props.value, '<span class="test">text</span>' ) ); }, isActive: props.isActive, } ); } wp.richText.registerFormatType( 'dammaj-editor/saws-output', { title: 'saws', tagName: '<span class="test">text</span>', className: null, edit: myCustomButton, } ); } )( window.wp );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to use richText.insert to insert HTML ?’ is closed to new replies.