最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I remove a button from the paragraph block toolbar?

programmeradmin4浏览0评论

I want to remove the bold option from the toolbar in the wordpress paragraph block. I did not find any documentation on that. The closiest thing I found was a tutorial to add buttons.

Any help would be appreciated.

I want to remove the bold option from the toolbar in the wordpress paragraph block. I did not find any documentation on that. The closiest thing I found was a tutorial to add buttons.

Any help would be appreciated.

Share Improve this question edited Apr 14, 2020 at 10:26 Tom J Nowell 61.1k7 gold badges79 silver badges148 bronze badges asked Apr 14, 2020 at 9:37 MarcMarc 3571 silver badge12 bronze badges 4
  • Can I ask why you need this? What is the problem you're trying to solve? I ask because there's a very high chance that your problem can be solved via other means, but because you specifically asked about the bold button in the paragraph toolbar, and provided no context for why, I can't help :( – Tom J Nowell Commented Apr 14, 2020 at 10:24
  • Yes. The graphic designer wants no bold at all. – Marc Commented Apr 14, 2020 at 10:34
  • So it's an aesthetic preference? I ask because if this were to fix a problem, e.g. no bold in image descriptions, etc then alternative solutions might be possible. – Tom J Nowell Commented Apr 14, 2020 at 11:04
  • Yes, it is an aesthetic preference. – Marc Commented Apr 15, 2020 at 10:28
Add a comment  | 

1 Answer 1

Reset to default 1

I want to remove the bold option from the toolbar in the wordpress paragraph block.

At the moment, it cannot be done, the paragraph block doesn't use the format API but instead hardcodes the markup for those buttons in the toolbar component

You could:

  • strip out the bold tags on save in PHP
  • hide the button using CSS
  • Add a CSS editor style so that the font weight of bold text is the same as unbolded text
  • Open a feature request on the GitHub repo for Gutenberg

But:

  • These won't prevent the bold shortcut of cmd+b
  • Users can still use markdown shortcuts by writing *bold text*
  • Users can also write the bold text somewhere else, then copy paste it into the paragraph block
发布评论

评论列表(0)

  1. 暂无评论