admin管理员组文章数量:1391951
I am trying to disable a gutenberg toolbar button added by myself following this tutorial. /
But there is no docs for disabling the toolbar button, i have tried to fiddle with isActive property of that button, setting it to true or false doesnt seem to have effect on toolbar button. There seems to be nothing in docs explaining this condition, I need a way to disable the toolbar button
I am trying to disable a gutenberg toolbar button added by myself following this tutorial. https://developer.wordpress/block-editor/tutorials/format-api/2-toolbar-button/
But there is no docs for disabling the toolbar button, i have tried to fiddle with isActive property of that button, setting it to true or false doesnt seem to have effect on toolbar button. There seems to be nothing in docs explaining this condition, I need a way to disable the toolbar button
Share Improve this question asked Feb 24, 2020 at 7:16 NaveenNaveen 1273 bronze badges1 Answer
Reset to default 0I have found that you could add a className attribute to the button and select the button by document.getElementsByClassName query selector. so the code would be this
( function( wp ) {
var MyCustomButton = function( props ) {
return wp.element.createElement(
wp.editor.RichTextToolbarButton, {
icon: 'editor-code',
title: 'Sample output',
className: "foo"
onClick: function() {
console.log( 'toggle format' );
},
}
);
}
wp.richText.registerFormatType(
'my-custom-format/sample-output', {
title: 'Sample output',
tagName: 'samp',
className: null,
edit: MyCustomButton,
}
);
} )( window.wp );
with className foo added to the button.
本文标签: block editorhow to disable a button added by a plugin in gutenberg toolbar
版权声明:本文标题:block editor - how to disable a button added by a plugin in gutenberg toolbar? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744718209a2621536.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论